Update BGFX and BX (nw)

This commit is contained in:
Branimir Karadžić 2016-04-27 17:57:45 +02:00 committed by Miodrag Milanovic
parent 29d7699569
commit 94c7dd996b
73 changed files with 2849 additions and 574 deletions

View File

@ -8,6 +8,10 @@ indent_size = 4
indent_style = space
indent_size = 2
[iqa/*]
indent_style = tab
indent_size = 4
[libsquish/*]
indent_style = tab
indent_size = 4

View File

@ -1084,7 +1084,7 @@ void domsg(struct Global *global,
;
tp = file ? file->filename : 0;
Error(global, "%s\"%s\", line %d: %s: ",
MSG_PREFIX, tp, global->infile->fp?global->line:file->line, severity);
MSG_PREFIX, tp, global->infile?global->line:(file?file->line:0), severity);
if(global->error)
global->error(global->userdata, ErrorMessage[error], arg);
#if defined(UNIX)

View File

@ -825,6 +825,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
glsl_sampler_dim sampler_dim = (glsl_sampler_dim)ir->sampler->type->sampler_dimensionality;
const bool is_shadow = ir->sampler->type->sampler_shadow;
const bool is_array = ir->sampler->type->sampler_array;
const bool is_msaa = ir->op == ir_txf_ms;
const glsl_type* uv_type = ir->coordinate->type;
const int uv_dim = uv_type->vector_elements;
int sampler_uv_dim = tex_sampler_dim_size[sampler_dim];
@ -832,6 +833,8 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
sampler_uv_dim += 1;
if (is_array)
sampler_uv_dim += 1;
if (is_msaa)
sampler_uv_dim += 1;
const bool is_proj = (uv_dim > sampler_uv_dim);
const bool is_lod = (ir->op == ir_txl);
@ -876,8 +879,10 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
}
else
{
if (ir->op == ir_txf)
if (ir->op == ir_txf
|| ir->op == ir_txf_ms) {
buffer.asprintf_append ("texelFetch");
}
else
buffer.asprintf_append ("texture");
}
@ -885,7 +890,7 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
if (is_array && state->EXT_texture_array_enable)
buffer.asprintf_append ("Array");
if (is_proj)
if (ir->op == ir_tex && is_proj)
buffer.asprintf_append ("Proj");
if (ir->op == ir_txl)
buffer.asprintf_append ("Lod");
@ -921,12 +926,12 @@ void ir_print_glsl_visitor::visit(ir_texture *ir)
ir->coordinate->accept(this);
// lod
if (ir->op == ir_txl || ir->op == ir_txf)
if (ir->op == ir_txl || ir->op == ir_txf || ir->op == ir_txf_ms)
{
buffer.asprintf_append (", ");
ir->lod_info.lod->accept(this);
}
// grad
if (ir->op == ir_txd)
{

View File

@ -40,18 +40,18 @@
/**
* Rounds a float to the nearest integer.
*/
IQA_EXPORT IQA_INLINE int _round(float a);
IQA_EXPORT int _round(float a);
IQA_EXPORT IQA_INLINE int _max(int x, int y);
IQA_EXPORT int _max(int x, int y);
IQA_EXPORT IQA_INLINE int _min(int x, int y);
IQA_EXPORT int _min(int x, int y);
/**
* Compares 2 floats to the specified digit of precision.
* @return 0 if equal, 1 otherwise.
*/
IQA_EXPORT IQA_INLINE int _cmp_float(float a, float b, int digits);
IQA_EXPORT int _cmp_float(float a, float b, int digits);
/**
@ -59,6 +59,6 @@ IQA_EXPORT IQA_INLINE int _cmp_float(float a, float b, int digits);
* same size as 'a' or smaller.
* @return 0 if equal, 1 otherwise
*/
IQA_EXPORT IQA_INLINE int _matrix_cmp(const float *a, const float *b, int w, int h, int digits);
IQA_EXPORT int _matrix_cmp(const float *a, const float *b, int w, int h, int digits);
#endif /*_MATH_UTILS_H_*/

View File

@ -2,7 +2,7 @@
// File: vk_platform.h
//
/*
** Copyright (c) 2014-2016 The Khronos Group Inc.
** Copyright (c) 2014-2015 The Khronos Group Inc.
**
** Permission is hereby granted, free of charge, to any person obtaining a
** copy of this software and/or associated documentation files (the
@ -25,8 +25,8 @@
*/
#ifndef __VK_PLATFORM_H__
#define __VK_PLATFORM_H__
#ifndef VK_PLATFORM_H_
#define VK_PLATFORM_H_
#ifdef __cplusplus
extern "C"
@ -124,4 +124,4 @@ extern "C"
#include <xcb/xcb.h>
#endif
#endif // __VK_PLATFORM_H__
#endif

View File

@ -40,12 +40,18 @@ extern "C" {
#define VK_MAKE_VERSION(major, minor, patch) \
(((major) << 22) | ((minor) << 12) | (patch))
// Vulkan API version supported by this file
#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 5)
// DEPRECATED: This define has been removed. Specific version defines (e.g. VK_API_VERSION_1_0), or the VK_MAKE_VERSION macro, should be used instead.
//#define VK_API_VERSION VK_MAKE_VERSION(1, 0, 0)
// Vulkan 1.0 version number
#define VK_API_VERSION_1_0 VK_MAKE_VERSION(1, 0, 0)
#define VK_VERSION_MAJOR(version) ((uint32_t)(version) >> 22)
#define VK_VERSION_MINOR(version) (((uint32_t)(version) >> 12) & 0x3ff)
#define VK_VERSION_PATCH(version) ((uint32_t)(version) & 0xfff)
// Version of this file
#define VK_HEADER_VERSION 8
#define VK_NULL_HANDLE 0
@ -680,6 +686,7 @@ typedef enum VkDynamicState {
typedef enum VkFilter {
VK_FILTER_NEAREST = 0,
VK_FILTER_LINEAR = 1,
VK_FILTER_CUBIC_IMG = 1000015000,
VK_FILTER_BEGIN_RANGE = VK_FILTER_NEAREST,
VK_FILTER_END_RANGE = VK_FILTER_LINEAR,
VK_FILTER_RANGE_SIZE = (VK_FILTER_LINEAR - VK_FILTER_NEAREST + 1),
@ -809,6 +816,8 @@ typedef enum VkFormatFeatureFlagBits {
VK_FORMAT_FEATURE_BLIT_SRC_BIT = 0x00000400,
VK_FORMAT_FEATURE_BLIT_DST_BIT = 0x00000800,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_LINEAR_BIT = 0x00001000,
VK_FORMAT_FEATURE_SAMPLED_IMAGE_FILTER_CUBIC_BIT_IMG = 0x00002000,
VK_FORMAT_FEATURE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkFormatFeatureFlagBits;
typedef VkFlags VkFormatFeatureFlags;
@ -821,6 +830,7 @@ typedef enum VkImageUsageFlagBits {
VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT = 0x00000020,
VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT = 0x00000040,
VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT = 0x00000080,
VK_IMAGE_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkImageUsageFlagBits;
typedef VkFlags VkImageUsageFlags;
@ -830,6 +840,7 @@ typedef enum VkImageCreateFlagBits {
VK_IMAGE_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT = 0x00000008,
VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT = 0x00000010,
VK_IMAGE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkImageCreateFlagBits;
typedef VkFlags VkImageCreateFlags;
@ -841,6 +852,7 @@ typedef enum VkSampleCountFlagBits {
VK_SAMPLE_COUNT_16_BIT = 0x00000010,
VK_SAMPLE_COUNT_32_BIT = 0x00000020,
VK_SAMPLE_COUNT_64_BIT = 0x00000040,
VK_SAMPLE_COUNT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkSampleCountFlagBits;
typedef VkFlags VkSampleCountFlags;
@ -849,6 +861,7 @@ typedef enum VkQueueFlagBits {
VK_QUEUE_COMPUTE_BIT = 0x00000002,
VK_QUEUE_TRANSFER_BIT = 0x00000004,
VK_QUEUE_SPARSE_BINDING_BIT = 0x00000008,
VK_QUEUE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkQueueFlagBits;
typedef VkFlags VkQueueFlags;
@ -858,11 +871,13 @@ typedef enum VkMemoryPropertyFlagBits {
VK_MEMORY_PROPERTY_HOST_COHERENT_BIT = 0x00000004,
VK_MEMORY_PROPERTY_HOST_CACHED_BIT = 0x00000008,
VK_MEMORY_PROPERTY_LAZILY_ALLOCATED_BIT = 0x00000010,
VK_MEMORY_PROPERTY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkMemoryPropertyFlagBits;
typedef VkFlags VkMemoryPropertyFlags;
typedef enum VkMemoryHeapFlagBits {
VK_MEMORY_HEAP_DEVICE_LOCAL_BIT = 0x00000001,
VK_MEMORY_HEAP_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkMemoryHeapFlagBits;
typedef VkFlags VkMemoryHeapFlags;
typedef VkFlags VkDeviceCreateFlags;
@ -886,6 +901,7 @@ typedef enum VkPipelineStageFlagBits {
VK_PIPELINE_STAGE_HOST_BIT = 0x00004000,
VK_PIPELINE_STAGE_ALL_GRAPHICS_BIT = 0x00008000,
VK_PIPELINE_STAGE_ALL_COMMANDS_BIT = 0x00010000,
VK_PIPELINE_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkPipelineStageFlagBits;
typedef VkFlags VkPipelineStageFlags;
typedef VkFlags VkMemoryMapFlags;
@ -895,6 +911,7 @@ typedef enum VkImageAspectFlagBits {
VK_IMAGE_ASPECT_DEPTH_BIT = 0x00000002,
VK_IMAGE_ASPECT_STENCIL_BIT = 0x00000004,
VK_IMAGE_ASPECT_METADATA_BIT = 0x00000008,
VK_IMAGE_ASPECT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkImageAspectFlagBits;
typedef VkFlags VkImageAspectFlags;
@ -902,16 +919,19 @@ typedef enum VkSparseImageFormatFlagBits {
VK_SPARSE_IMAGE_FORMAT_SINGLE_MIPTAIL_BIT = 0x00000001,
VK_SPARSE_IMAGE_FORMAT_ALIGNED_MIP_SIZE_BIT = 0x00000002,
VK_SPARSE_IMAGE_FORMAT_NONSTANDARD_BLOCK_SIZE_BIT = 0x00000004,
VK_SPARSE_IMAGE_FORMAT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkSparseImageFormatFlagBits;
typedef VkFlags VkSparseImageFormatFlags;
typedef enum VkSparseMemoryBindFlagBits {
VK_SPARSE_MEMORY_BIND_METADATA_BIT = 0x00000001,
VK_SPARSE_MEMORY_BIND_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkSparseMemoryBindFlagBits;
typedef VkFlags VkSparseMemoryBindFlags;
typedef enum VkFenceCreateFlagBits {
VK_FENCE_CREATE_SIGNALED_BIT = 0x00000001,
VK_FENCE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkFenceCreateFlagBits;
typedef VkFlags VkFenceCreateFlags;
typedef VkFlags VkSemaphoreCreateFlags;
@ -930,6 +950,7 @@ typedef enum VkQueryPipelineStatisticFlagBits {
VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_CONTROL_SHADER_PATCHES_BIT = 0x00000100,
VK_QUERY_PIPELINE_STATISTIC_TESSELLATION_EVALUATION_SHADER_INVOCATIONS_BIT = 0x00000200,
VK_QUERY_PIPELINE_STATISTIC_COMPUTE_SHADER_INVOCATIONS_BIT = 0x00000400,
VK_QUERY_PIPELINE_STATISTIC_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkQueryPipelineStatisticFlagBits;
typedef VkFlags VkQueryPipelineStatisticFlags;
@ -938,6 +959,7 @@ typedef enum VkQueryResultFlagBits {
VK_QUERY_RESULT_WAIT_BIT = 0x00000002,
VK_QUERY_RESULT_WITH_AVAILABILITY_BIT = 0x00000004,
VK_QUERY_RESULT_PARTIAL_BIT = 0x00000008,
VK_QUERY_RESULT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkQueryResultFlagBits;
typedef VkFlags VkQueryResultFlags;
@ -945,6 +967,7 @@ typedef enum VkBufferCreateFlagBits {
VK_BUFFER_CREATE_SPARSE_BINDING_BIT = 0x00000001,
VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT = 0x00000002,
VK_BUFFER_CREATE_SPARSE_ALIASED_BIT = 0x00000004,
VK_BUFFER_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkBufferCreateFlagBits;
typedef VkFlags VkBufferCreateFlags;
@ -958,6 +981,7 @@ typedef enum VkBufferUsageFlagBits {
VK_BUFFER_USAGE_INDEX_BUFFER_BIT = 0x00000040,
VK_BUFFER_USAGE_VERTEX_BUFFER_BIT = 0x00000080,
VK_BUFFER_USAGE_INDIRECT_BUFFER_BIT = 0x00000100,
VK_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkBufferUsageFlagBits;
typedef VkFlags VkBufferUsageFlags;
typedef VkFlags VkBufferViewCreateFlags;
@ -969,6 +993,7 @@ typedef enum VkPipelineCreateFlagBits {
VK_PIPELINE_CREATE_DISABLE_OPTIMIZATION_BIT = 0x00000001,
VK_PIPELINE_CREATE_ALLOW_DERIVATIVES_BIT = 0x00000002,
VK_PIPELINE_CREATE_DERIVATIVE_BIT = 0x00000004,
VK_PIPELINE_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkPipelineCreateFlagBits;
typedef VkFlags VkPipelineCreateFlags;
typedef VkFlags VkPipelineShaderStageCreateFlags;
@ -982,6 +1007,7 @@ typedef enum VkShaderStageFlagBits {
VK_SHADER_STAGE_COMPUTE_BIT = 0x00000020,
VK_SHADER_STAGE_ALL_GRAPHICS = 0x0000001F,
VK_SHADER_STAGE_ALL = 0x7FFFFFFF,
VK_SHADER_STAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkShaderStageFlagBits;
typedef VkFlags VkPipelineVertexInputStateCreateFlags;
typedef VkFlags VkPipelineInputAssemblyStateCreateFlags;
@ -994,6 +1020,7 @@ typedef enum VkCullModeFlagBits {
VK_CULL_MODE_FRONT_BIT = 0x00000001,
VK_CULL_MODE_BACK_BIT = 0x00000002,
VK_CULL_MODE_FRONT_AND_BACK = 0x00000003,
VK_CULL_MODE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkCullModeFlagBits;
typedef VkFlags VkCullModeFlags;
typedef VkFlags VkPipelineMultisampleStateCreateFlags;
@ -1005,6 +1032,7 @@ typedef enum VkColorComponentFlagBits {
VK_COLOR_COMPONENT_G_BIT = 0x00000002,
VK_COLOR_COMPONENT_B_BIT = 0x00000004,
VK_COLOR_COMPONENT_A_BIT = 0x00000008,
VK_COLOR_COMPONENT_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkColorComponentFlagBits;
typedef VkFlags VkColorComponentFlags;
typedef VkFlags VkPipelineDynamicStateCreateFlags;
@ -1015,6 +1043,7 @@ typedef VkFlags VkDescriptorSetLayoutCreateFlags;
typedef enum VkDescriptorPoolCreateFlagBits {
VK_DESCRIPTOR_POOL_CREATE_FREE_DESCRIPTOR_SET_BIT = 0x00000001,
VK_DESCRIPTOR_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkDescriptorPoolCreateFlagBits;
typedef VkFlags VkDescriptorPoolCreateFlags;
typedef VkFlags VkDescriptorPoolResetFlags;
@ -1023,6 +1052,7 @@ typedef VkFlags VkRenderPassCreateFlags;
typedef enum VkAttachmentDescriptionFlagBits {
VK_ATTACHMENT_DESCRIPTION_MAY_ALIAS_BIT = 0x00000001,
VK_ATTACHMENT_DESCRIPTION_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkAttachmentDescriptionFlagBits;
typedef VkFlags VkAttachmentDescriptionFlags;
typedef VkFlags VkSubpassDescriptionFlags;
@ -1045,22 +1075,26 @@ typedef enum VkAccessFlagBits {
VK_ACCESS_HOST_WRITE_BIT = 0x00004000,
VK_ACCESS_MEMORY_READ_BIT = 0x00008000,
VK_ACCESS_MEMORY_WRITE_BIT = 0x00010000,
VK_ACCESS_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkAccessFlagBits;
typedef VkFlags VkAccessFlags;
typedef enum VkDependencyFlagBits {
VK_DEPENDENCY_BY_REGION_BIT = 0x00000001,
VK_DEPENDENCY_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkDependencyFlagBits;
typedef VkFlags VkDependencyFlags;
typedef enum VkCommandPoolCreateFlagBits {
VK_COMMAND_POOL_CREATE_TRANSIENT_BIT = 0x00000001,
VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT = 0x00000002,
VK_COMMAND_POOL_CREATE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkCommandPoolCreateFlagBits;
typedef VkFlags VkCommandPoolCreateFlags;
typedef enum VkCommandPoolResetFlagBits {
VK_COMMAND_POOL_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
VK_COMMAND_POOL_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkCommandPoolResetFlagBits;
typedef VkFlags VkCommandPoolResetFlags;
@ -1068,16 +1102,19 @@ typedef enum VkCommandBufferUsageFlagBits {
VK_COMMAND_BUFFER_USAGE_ONE_TIME_SUBMIT_BIT = 0x00000001,
VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT = 0x00000002,
VK_COMMAND_BUFFER_USAGE_SIMULTANEOUS_USE_BIT = 0x00000004,
VK_COMMAND_BUFFER_USAGE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkCommandBufferUsageFlagBits;
typedef VkFlags VkCommandBufferUsageFlags;
typedef enum VkQueryControlFlagBits {
VK_QUERY_CONTROL_PRECISE_BIT = 0x00000001,
VK_QUERY_CONTROL_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkQueryControlFlagBits;
typedef VkFlags VkQueryControlFlags;
typedef enum VkCommandBufferResetFlagBits {
VK_COMMAND_BUFFER_RESET_RELEASE_RESOURCES_BIT = 0x00000001,
VK_COMMAND_BUFFER_RESET_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkCommandBufferResetFlagBits;
typedef VkFlags VkCommandBufferResetFlags;
@ -1085,6 +1122,7 @@ typedef enum VkStencilFaceFlagBits {
VK_STENCIL_FACE_FRONT_BIT = 0x00000001,
VK_STENCIL_FACE_BACK_BIT = 0x00000002,
VK_STENCIL_FRONT_AND_BACK = 0x00000003,
VK_STENCIL_FACE_FLAG_BITS_MAX_ENUM = 0x7FFFFFFF
} VkStencilFaceFlagBits;
typedef VkFlags VkStencilFaceFlags;
@ -3141,10 +3179,10 @@ VK_DEFINE_NON_DISPATCHABLE_HANDLE(VkSurfaceKHR)
typedef enum VkColorSpaceKHR {
VK_COLORSPACE_SRGB_NONLINEAR_KHR = 0,
VK_COLORSPACE_BEGIN_RANGE = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLORSPACE_END_RANGE = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLORSPACE_RANGE_SIZE = (VK_COLORSPACE_SRGB_NONLINEAR_KHR - VK_COLORSPACE_SRGB_NONLINEAR_KHR + 1),
VK_COLORSPACE_MAX_ENUM = 0x7FFFFFFF
VK_COLOR_SPACE_BEGIN_RANGE_KHR = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_END_RANGE_KHR = VK_COLORSPACE_SRGB_NONLINEAR_KHR,
VK_COLOR_SPACE_RANGE_SIZE_KHR = (VK_COLORSPACE_SRGB_NONLINEAR_KHR - VK_COLORSPACE_SRGB_NONLINEAR_KHR + 1),
VK_COLOR_SPACE_MAX_ENUM_KHR = 0x7FFFFFFF
} VkColorSpaceKHR;
typedef enum VkPresentModeKHR {
@ -3152,10 +3190,10 @@ typedef enum VkPresentModeKHR {
VK_PRESENT_MODE_MAILBOX_KHR = 1,
VK_PRESENT_MODE_FIFO_KHR = 2,
VK_PRESENT_MODE_FIFO_RELAXED_KHR = 3,
VK_PRESENT_MODE_BEGIN_RANGE = VK_PRESENT_MODE_IMMEDIATE_KHR,
VK_PRESENT_MODE_END_RANGE = VK_PRESENT_MODE_FIFO_RELAXED_KHR,
VK_PRESENT_MODE_RANGE_SIZE = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1),
VK_PRESENT_MODE_MAX_ENUM = 0x7FFFFFFF
VK_PRESENT_MODE_BEGIN_RANGE_KHR = VK_PRESENT_MODE_IMMEDIATE_KHR,
VK_PRESENT_MODE_END_RANGE_KHR = VK_PRESENT_MODE_FIFO_RELAXED_KHR,
VK_PRESENT_MODE_RANGE_SIZE_KHR = (VK_PRESENT_MODE_FIFO_RELAXED_KHR - VK_PRESENT_MODE_IMMEDIATE_KHR + 1),
VK_PRESENT_MODE_MAX_ENUM_KHR = 0x7FFFFFFF
} VkPresentModeKHR;
@ -3169,6 +3207,7 @@ typedef enum VkSurfaceTransformFlagBitsKHR {
VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_180_BIT_KHR = 0x00000040,
VK_SURFACE_TRANSFORM_HORIZONTAL_MIRROR_ROTATE_270_BIT_KHR = 0x00000080,
VK_SURFACE_TRANSFORM_INHERIT_BIT_KHR = 0x00000100,
VK_SURFACE_TRANSFORM_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkSurfaceTransformFlagBitsKHR;
typedef VkFlags VkSurfaceTransformFlagsKHR;
@ -3177,6 +3216,7 @@ typedef enum VkCompositeAlphaFlagBitsKHR {
VK_COMPOSITE_ALPHA_PRE_MULTIPLIED_BIT_KHR = 0x00000002,
VK_COMPOSITE_ALPHA_POST_MULTIPLIED_BIT_KHR = 0x00000004,
VK_COMPOSITE_ALPHA_INHERIT_BIT_KHR = 0x00000008,
VK_COMPOSITE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkCompositeAlphaFlagBitsKHR;
typedef VkFlags VkCompositeAlphaFlagsKHR;
@ -3326,6 +3366,7 @@ typedef enum VkDisplayPlaneAlphaFlagBitsKHR {
VK_DISPLAY_PLANE_ALPHA_GLOBAL_BIT_KHR = 0x00000002,
VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_BIT_KHR = 0x00000004,
VK_DISPLAY_PLANE_ALPHA_PER_PIXEL_PREMULTIPLIED_BIT_KHR = 0x00000008,
VK_DISPLAY_PLANE_ALPHA_FLAG_BITS_MAX_ENUM_KHR = 0x7FFFFFFF
} VkDisplayPlaneAlphaFlagBitsKHR;
typedef VkFlags VkDisplayPlaneAlphaFlagsKHR;
typedef VkFlags VkDisplayModeCreateFlagsKHR;
@ -3711,11 +3752,19 @@ typedef enum VkDebugReportObjectTypeEXT {
VK_DEBUG_REPORT_OBJECT_TYPE_SURFACE_KHR_EXT = 26,
VK_DEBUG_REPORT_OBJECT_TYPE_SWAPCHAIN_KHR_EXT = 27,
VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT = 28,
VK_DEBUG_REPORT_OBJECT_TYPE_BEGIN_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT,
VK_DEBUG_REPORT_OBJECT_TYPE_END_RANGE_EXT = VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT,
VK_DEBUG_REPORT_OBJECT_TYPE_RANGE_SIZE_EXT = (VK_DEBUG_REPORT_OBJECT_TYPE_DEBUG_REPORT_EXT - VK_DEBUG_REPORT_OBJECT_TYPE_UNKNOWN_EXT + 1),
VK_DEBUG_REPORT_OBJECT_TYPE_MAX_ENUM_EXT = 0x7FFFFFFF
} VkDebugReportObjectTypeEXT;
typedef enum VkDebugReportErrorEXT {
VK_DEBUG_REPORT_ERROR_NONE_EXT = 0,
VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT = 1,
VK_DEBUG_REPORT_ERROR_BEGIN_RANGE_EXT = VK_DEBUG_REPORT_ERROR_NONE_EXT,
VK_DEBUG_REPORT_ERROR_END_RANGE_EXT = VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT,
VK_DEBUG_REPORT_ERROR_RANGE_SIZE_EXT = (VK_DEBUG_REPORT_ERROR_CALLBACK_REF_EXT - VK_DEBUG_REPORT_ERROR_NONE_EXT + 1),
VK_DEBUG_REPORT_ERROR_MAX_ENUM_EXT = 0x7FFFFFFF
} VkDebugReportErrorEXT;
@ -3725,6 +3774,7 @@ typedef enum VkDebugReportFlagBitsEXT {
VK_DEBUG_REPORT_PERFORMANCE_WARNING_BIT_EXT = 0x00000004,
VK_DEBUG_REPORT_ERROR_BIT_EXT = 0x00000008,
VK_DEBUG_REPORT_DEBUG_BIT_EXT = 0x00000010,
VK_DEBUG_REPORT_FLAG_BITS_MAX_ENUM_EXT = 0x7FFFFFFF
} VkDebugReportFlagBitsEXT;
typedef VkFlags VkDebugReportFlagsEXT;
@ -3780,6 +3830,11 @@ VKAPI_ATTR void VKAPI_CALL vkDebugReportMessageEXT(
#define VK_NV_GLSL_SHADER_EXTENSION_NAME "VK_NV_glsl_shader"
#define VK_IMG_filter_cubic 1
#define VK_IMG_FILTER_CUBIC_SPEC_VERSION 1
#define VK_IMG_FILTER_CUBIC_EXTENSION_NAME "VK_IMG_filter_cubic"
#ifdef __cplusplus
}
#endif

View File

@ -534,6 +534,7 @@
- style: try to make PushStyleVar() more robust to incorrect parameters (to be more friendly to edit & continues situation).
- style/opt: PopStyleVar could be optimized by having GetStyleVar returns the type, using a table mapping stylevar enum to data type.
- style: global scale setting.
- style: WindowPadding needs to be EVEN needs the 0.5 multiplier probably have a subtle effect on clip rectangle
- text: simple markup language for color change?
- font: dynamic font atlas to avoid baking huge ranges into bitmap and make scaling easier.
- font: helper to add glyph redirect/replacements (e.g. redirect alternate apostrophe unicode code points to ascii one, etc.)
@ -558,7 +559,8 @@
- remote: make a system like RemoteImGui first-class citizen/project (#75)
!- demo: custom render demo pushes a clipping rectangle past parent window bounds. expose ImGui::PushClipRect() from imgui_internal.h?
- drawlist: end-user probably can't call Clear() directly because we expect a texture to be pushed in the stack.
- examples: directx9/directx11: save/restore device state more thoroughly.
- examples: directx9: save/restore device state more thoroughly.
- examples: window minimize, maximize (#583)
- optimization: use another hash function than crc32, e.g. FNV1a
- optimization/render: merge command-lists with same clip-rect into one even if they aren't sequential? (as long as in-between clip rectangle don't overlap)?
- optimization: turn some the various stack vectors into statically-sized arrays
@ -633,7 +635,6 @@ static inline bool IsWindowContentHoverable(ImGuiWindow* window);
static void ClearSetNextWindowData();
static void CheckStacksSize(ImGuiWindow* window, bool write);
static void Scrollbar(ImGuiWindow* window, bool horizontal);
static bool CloseWindowButton(bool* p_opened);
static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_list, ImDrawList* draw_list);
static void AddWindowToRenderList(ImVector<ImDrawList*>& out_render_list, ImGuiWindow* window);
@ -1575,6 +1576,7 @@ ImGuiWindow::ImGuiWindow(const char* name)
MoveID = GetID("#MOVE");
Flags = 0;
IndexWithinParent = 0;
PosFloat = Pos = ImVec2(0.0f, 0.0f);
Size = SizeFull = ImVec2(0.0f, 0.0f);
SizeContents = SizeContentsExplicit = ImVec2(0.0f, 0.0f);
@ -2305,7 +2307,7 @@ static int ChildWindowComparer(const void* lhs, const void* rhs)
return d;
if (int d = (a->Flags & ImGuiWindowFlags_ComboBox) - (b->Flags & ImGuiWindowFlags_ComboBox))
return d;
return 0;
return (a->IndexWithinParent - b->IndexWithinParent);
}
static void AddWindowToSortedBuffer(ImVector<ImGuiWindow*>& out_sorted_windows, ImGuiWindow* window)
@ -2339,9 +2341,13 @@ static void AddDrawListToRenderList(ImVector<ImDrawList*>& out_render_list, ImDr
return;
}
// Draw list sanity check. Detect mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
IM_ASSERT(draw_list->_VtxWritePtr == draw_list->VtxBuffer.Data + draw_list->VtxBuffer.Size);
IM_ASSERT(draw_list->_IdxWritePtr == draw_list->IdxBuffer.Data + draw_list->IdxBuffer.Size);
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size);
// Check that draw_list doesn't use more vertices than indexable (default ImDrawIdx = 2 bytes = 64K vertices)
// If this assert triggers because you are drawing lots of stuff manually, A) workaround by calling BeginChild()/EndChild() to put your draw commands in multiple draw lists, B) #define ImDrawIdx to a 'unsigned int' in imconfig.h and render accordingly.
IM_ASSERT((int)draw_list->_VtxCurrentIdx == draw_list->VtxBuffer.Size); // Sanity check. Bug or mismatch between PrimReserve() calls and incrementing _VtxCurrentIdx, _VtxWritePtr etc.
IM_ASSERT((int64_t)draw_list->_VtxCurrentIdx <= ((int64_t)1L << (sizeof(ImDrawIdx)*8))); // Too many vertices in same ImDrawList. See comment above.
out_render_list.push_back(draw_list);
@ -2368,13 +2374,14 @@ void ImGui::PushClipRect(const ImVec2& clip_rect_min, const ImVec2& clip_rect_ma
ImGuiWindow* window = GetCurrentWindow();
ImRect cr(clip_rect_min, clip_rect_max);
if (intersect_with_existing_clip_rect)
{
// Clip our argument with the current clip rect
if (intersect_with_existing_clip_rect) // Clip our argument with the current clip rect
cr.Clip(window->ClipRect);
}
cr.Max.x = ImMax(cr.Min.x, cr.Max.x);
cr.Max.y = ImMax(cr.Min.y, cr.Max.y);
cr.Min.x = (float)(int)(cr.Min.x + 0.5f); // Round (expecting to round down). Ensure that e.g. (int)(max.x-min.x) in user code produce correct result.
cr.Min.y = (float)(int)(cr.Min.y + 0.5f);
cr.Max.x = (float)(int)(cr.Max.x + 0.5f);
cr.Max.y = (float)(int)(cr.Max.y + 0.5f);
IM_ASSERT(cr.Min.x <= cr.Max.x && cr.Min.y <= cr.Max.y);
window->ClipRect = cr;
@ -3372,7 +3379,7 @@ bool ImGui::BeginChild(const char* str_id, const ImVec2& size_arg, bool border,
ImGuiWindowFlags flags = ImGuiWindowFlags_NoTitleBar|ImGuiWindowFlags_NoResize|ImGuiWindowFlags_NoSavedSettings|ImGuiWindowFlags_ChildWindow;
const ImVec2 content_avail = ImGui::GetContentRegionAvail();
ImVec2 size = ImRound(size_arg);
ImVec2 size = ImFloor(size_arg);
if (size.x <= 0.0f)
{
if (size.x == 0.0f)
@ -3696,6 +3703,7 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
if (first_begin_of_the_frame)
{
window->Active = true;
window->IndexWithinParent = 0;
window->BeginCount = 0;
window->DrawList->Clear();
window->ClipRect = ImVec4(-FLT_MAX,-FLT_MAX,+FLT_MAX,+FLT_MAX);
@ -3826,7 +3834,10 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
// Position child window
if (flags & ImGuiWindowFlags_ChildWindow)
{
window->IndexWithinParent = parent_window->DC.ChildWindows.Size;
parent_window->DC.ChildWindows.push_back(window);
}
if ((flags & ImGuiWindowFlags_ChildWindow) && !(flags & ImGuiWindowFlags_Popup))
{
window->Pos = window->PosFloat = parent_window->DC.CursorPos;
@ -4007,6 +4018,8 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
{
ImRect menu_bar_rect = window->MenuBarRect();
window->DrawList->AddRectFilled(menu_bar_rect.GetTL(), menu_bar_rect.GetBR(), GetColorU32(ImGuiCol_MenuBarBg), (flags & ImGuiWindowFlags_NoTitleBar) ? window_rounding : 0.0f, 1|2);
if (flags & ImGuiWindowFlags_ShowBorders)
window->DrawList->AddLine(menu_bar_rect.GetBL()-ImVec2(0,0), menu_bar_rect.GetBR()-ImVec2(0,0), GetColorU32(ImGuiCol_Border));
}
// Scrollbars
@ -4077,7 +4090,12 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
if (!(flags & ImGuiWindowFlags_NoTitleBar))
{
if (p_opened != NULL)
CloseWindowButton(p_opened);
{
const float pad = 2.0f;
const float rad = (window->TitleBarHeight() - pad*2.0f) * 0.5f;
if (CloseButton(window->GetID("#CLOSE"), window->Rect().GetTR() + ImVec2(-pad - rad, pad + rad), rad))
*p_opened = false;
}
const ImVec2 text_size = CalcTextSize(name, NULL, true);
if (!(flags & ImGuiWindowFlags_NoCollapse))
@ -4114,9 +4132,9 @@ bool ImGui::Begin(const char* name, bool* p_opened, const ImVec2& size_on_first_
const ImRect title_bar_rect = window->TitleBarRect();
const float border_size = window->BorderSize;
ImRect clip_rect;
clip_rect.Min.x = title_bar_rect.Min.x + 0.5f + ImMax(border_size, window->WindowPadding.x*0.5f);
clip_rect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + 0.5f + border_size;
clip_rect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - ImMax(border_size, window->WindowPadding.x*0.5f);
clip_rect.Min.x = title_bar_rect.Min.x + ImMax(border_size, (float)(int)(window->WindowPadding.x*0.5f));
clip_rect.Min.y = title_bar_rect.Max.y + window->MenuBarHeight() + border_size;
clip_rect.Max.x = window->Pos.x + window->Size.x - window->ScrollbarSizes.x - ImMax(border_size, (float)(int)(window->WindowPadding.x*0.5f));
clip_rect.Max.y = window->Pos.y + window->Size.y - border_size - window->ScrollbarSizes.y;
PushClipRect(clip_rect.Min, clip_rect.Max, true);
@ -4189,14 +4207,14 @@ static void Scrollbar(ImGuiWindow* window, bool horizontal)
? ImRect(window->Pos.x + border_size, window_rect.Max.y - style.ScrollbarSize, window_rect.Max.x - other_scrollbar_size_w - border_size, window_rect.Max.y - border_size)
: ImRect(window_rect.Max.x - style.ScrollbarSize, window->Pos.y + border_size, window_rect.Max.x - border_size, window_rect.Max.y - other_scrollbar_size_w - border_size);
if (!horizontal)
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() - border_size : 0.0f);
bb.Min.y += window->TitleBarHeight() + ((window->Flags & ImGuiWindowFlags_MenuBar) ? window->MenuBarHeight() : 0.0f);
float window_rounding = (window->Flags & ImGuiWindowFlags_ChildWindow) ? style.ChildWindowRounding : style.WindowRounding;
int window_rounding_corners;
if (horizontal)
window_rounding_corners = 8 | (other_scrollbar ? 0 : 4);
else
window_rounding_corners = ((window->Flags & ImGuiWindowFlags_NoTitleBar) ? 2 : 0) | (other_scrollbar ? 0 : 4);
window_rounding_corners = (((window->Flags & ImGuiWindowFlags_NoTitleBar) && !(window->Flags & ImGuiWindowFlags_MenuBar)) ? 2 : 0) | (other_scrollbar ? 0 : 4);
window->DrawList->AddRectFilled(bb.Min, bb.Max, ImGui::GetColorU32(ImGuiCol_ScrollbarBg), window_rounding, window_rounding_corners);
bb.Reduce(ImVec2(ImClamp((float)(int)((bb.Max.x - bb.Min.x - 2.0f) * 0.5f), 0.0f, 3.0f), ImClamp((float)(int)((bb.Max.y - bb.Min.y - 2.0f) * 0.5f), 0.0f, 3.0f)));
@ -5385,13 +5403,11 @@ bool ImGui::InvisibleButton(const char* str_id, const ImVec2& size_arg)
}
// Upper-right button to close a window.
static bool CloseWindowButton(bool* p_opened)
bool ImGui::CloseButton(ImGuiID id, const ImVec2& pos, float radius)
{
ImGuiWindow* window = ImGui::GetCurrentWindow();
const ImGuiID id = window->GetID("#CLOSE");
const float size = window->TitleBarHeight() - 4.0f;
const ImRect bb(window->Rect().GetTR() + ImVec2(-2.0f-size,2.0f), window->Rect().GetTR() + ImVec2(-2.0f,2.0f+size));
const ImRect bb(pos - ImVec2(radius,radius), pos + ImVec2(radius,radius));
bool hovered, held;
bool pressed = ImGui::ButtonBehavior(bb, id, &hovered, &held);
@ -5399,18 +5415,15 @@ static bool CloseWindowButton(bool* p_opened)
// Render
const ImU32 col = ImGui::GetColorU32((held && hovered) ? ImGuiCol_CloseButtonActive : hovered ? ImGuiCol_CloseButtonHovered : ImGuiCol_CloseButton);
const ImVec2 center = bb.GetCenter();
window->DrawList->AddCircleFilled(center, ImMax(2.0f,size*0.5f), col, 16);
window->DrawList->AddCircleFilled(center, ImMax(2.0f, radius), col, 12);
const float cross_extent = (size * 0.5f * 0.7071f) - 1.0f;
const float cross_extent = (radius * 0.7071f) - 1.0f;
if (hovered)
{
window->DrawList->AddLine(center + ImVec2(+cross_extent,+cross_extent), center + ImVec2(-cross_extent,-cross_extent), ImGui::GetColorU32(ImGuiCol_Text));
window->DrawList->AddLine(center + ImVec2(+cross_extent,-cross_extent), center + ImVec2(-cross_extent,+cross_extent), ImGui::GetColorU32(ImGuiCol_Text));
}
if (p_opened != NULL && pressed)
*p_opened = false;
return pressed;
}
@ -5718,65 +5731,6 @@ bool ImGui::CollapsingHeader(const char* label, const char* str_id, bool display
return opened;
}
void ImGui::Bullet()
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
ItemSize(bb);
if (!ItemAdd(bb, NULL))
{
ImGui::SameLine(0, style.FramePadding.x*2);
return;
}
// Render
const float bullet_size = g.FontSize*0.15f;
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
// Stay on same line
ImGui::SameLine(0, style.FramePadding.x*2);
}
// Text with a little bullet aligned to the typical tree node.
void ImGui::BulletTextV(const char* fmt, va_list args)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
const char* text_begin = g.TempBuffer;
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
ItemSize(bb);
if (!ItemAdd(bb, NULL))
return;
// Render
const float bullet_size = g.FontSize*0.15f;
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end);
}
void ImGui::BulletText(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
BulletTextV(fmt, args);
va_end(args);
}
// If returning 'true' the node is open and the user is responsible for calling TreePop
bool ImGui::TreeNodeV(const char* str_id, const char* fmt, va_list args)
{
@ -5898,6 +5852,65 @@ ImGuiID ImGui::GetID(const void* ptr_id)
return GImGui->CurrentWindow->GetID(ptr_id);
}
void ImGui::Bullet()
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize, line_height));
ItemSize(bb);
if (!ItemAdd(bb, NULL))
{
ImGui::SameLine(0, style.FramePadding.x*2);
return;
}
// Render
const float bullet_size = g.FontSize*0.15f;
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
// Stay on same line
ImGui::SameLine(0, style.FramePadding.x*2);
}
// Text with a little bullet aligned to the typical tree node.
void ImGui::BulletTextV(const char* fmt, va_list args)
{
ImGuiWindow* window = GetCurrentWindow();
if (window->SkipItems)
return;
ImGuiState& g = *GImGui;
const ImGuiStyle& style = g.Style;
const char* text_begin = g.TempBuffer;
const char* text_end = text_begin + ImFormatStringV(g.TempBuffer, IM_ARRAYSIZE(g.TempBuffer), fmt, args);
const ImVec2 label_size = CalcTextSize(text_begin, text_end, true);
const float text_base_offset_y = ImMax(0.0f, window->DC.CurrentLineTextBaseOffset); // Latch before ItemSize changes it
const float line_height = ImMax(ImMin(window->DC.CurrentLineHeight, g.FontSize + g.Style.FramePadding.y*2), g.FontSize);
const ImRect bb(window->DC.CursorPos, window->DC.CursorPos + ImVec2(g.FontSize + (label_size.x > 0.0f ? (label_size.x + style.FramePadding.x*2) : 0.0f), ImMax(line_height, label_size.y))); // Empty text doesn't add padding
ItemSize(bb);
if (!ItemAdd(bb, NULL))
return;
// Render
const float bullet_size = g.FontSize*0.15f;
window->DrawList->AddCircleFilled(bb.Min + ImVec2(style.FramePadding.x + g.FontSize*0.5f, line_height*0.5f), bullet_size, GetColorU32(ImGuiCol_Text));
RenderText(bb.Min+ImVec2(g.FontSize + style.FramePadding.x*2, text_base_offset_y), text_begin, text_end);
}
void ImGui::BulletText(const char* fmt, ...)
{
va_list args;
va_start(args, fmt);
BulletTextV(fmt, args);
va_end(args);
}
static inline void DataTypeFormatString(ImGuiDataType data_type, void* data_ptr, const char* display_format, char* buf, int buf_size)
{
if (data_type == ImGuiDataType_Int)
@ -7794,10 +7807,11 @@ bool ImGui::InputTextEx(const char* label, char* buf, int buf_size, const ImVec2
draw_window->DrawList->AddText(g.Font, g.FontSize, render_pos - render_scroll, GetColorU32(ImGuiCol_Text), buf, buf+edit_state.CurLenA, 0.0f, is_multiline ? NULL : &clip_rect);
// Draw blinking cursor
ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
bool cursor_is_visible = (g.InputTextState.CursorAnim <= 0.0f) || fmodf(g.InputTextState.CursorAnim, 1.20f) <= 0.80f;
if (cursor_is_visible)
draw_window->DrawList->AddLine(cursor_screen_pos + ImVec2(0.0f,-g.FontSize+0.5f), cursor_screen_pos + ImVec2(0.0f,-1.5f), GetColorU32(ImGuiCol_Text));
ImVec2 cursor_screen_pos = render_pos + cursor_offset - render_scroll;
ImRect cursor_screen_rect(cursor_screen_pos.x, cursor_screen_pos.y-g.FontSize+0.5f, cursor_screen_pos.x, cursor_screen_pos.y-1.5f);
if (cursor_is_visible && cursor_screen_rect.Overlaps(clip_rect))
draw_window->DrawList->AddLine(cursor_screen_rect.Min, cursor_screen_rect.Max, GetColorU32(ImGuiCol_Text));
// Notify OS of text input position for advanced IME (-1 x offset so that Windows IME can cover our cursor. Bit of an extra nicety.)
if (is_editable)
@ -8423,7 +8437,7 @@ bool ImGui::BeginMenuBar()
ImGui::BeginGroup(); // Save position
ImGui::PushID("##menubar");
ImRect rect = window->MenuBarRect();
PushClipRect(ImVec2(rect.Min.x+0.5f, rect.Min.y-0.5f+window->BorderSize), ImVec2(rect.Max.x+0.5f, rect.Max.y-0.5f), false);
PushClipRect(ImVec2(rect.Min.x, rect.Min.y + window->BorderSize), ImVec2(rect.Max.x, rect.Max.y), false);
window->DC.CursorPos = ImVec2(rect.Min.x + window->DC.MenuBarOffsetX, rect.Min.y);// + g.Style.FramePadding.y);
window->DC.LayoutType = ImGuiLayoutType_Horizontal;
window->DC.MenuBarAppending = true;
@ -8802,6 +8816,7 @@ bool ImGui::IsRectVisible(const ImVec2& size)
return window->ClipRect.Overlaps(ImRect(window->DC.CursorPos, window->DC.CursorPos + size));
}
// Lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
void ImGui::BeginGroup()
{
ImGuiWindow* window = GetCurrentWindow();
@ -9045,7 +9060,6 @@ void ImGui::Columns(int columns_count, const char* id, bool border)
{
if (g.ActiveIdIsJustActivated)
g.ActiveClickDeltaToCenter.x = x - g.IO.MousePos.x;
x = GetDraggedColumnOffset(i);
SetColumnOffset(i, x);
}
@ -9343,8 +9357,8 @@ void ImGui::ShowMetricsWindow(bool* opened)
ImDrawIdx* idx_buffer = (draw_list->IdxBuffer.Size > 0) ? draw_list->IdxBuffer.Data : NULL;
for (int i = elem_offset; i < elem_offset + (int)pcmd->ElemCount; i++)
vtxs_rect.Add(draw_list->VtxBuffer[idx_buffer ? idx_buffer[i] : i].pos);
clip_rect.Round(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
vtxs_rect.Round(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
clip_rect.Floor(); overlay_draw_list->AddRect(clip_rect.Min, clip_rect.Max, ImColor(255,255,0));
vtxs_rect.Floor(); overlay_draw_list->AddRect(vtxs_rect.Min, vtxs_rect.Max, ImColor(255,0,255));
}
if (!draw_opened)
continue;

View File

@ -187,14 +187,14 @@ namespace ImGui
IMGUI_API void PopButtonRepeat();
// Cursor / Layout
IMGUI_API void BeginGroup(); // lock horizontal starting position. once closing a group it is seen as a single item (so you can use IsItemHovered() on a group, SameLine() between groups, etc.
IMGUI_API void EndGroup();
IMGUI_API void Separator(); // horizontal line
IMGUI_API void SameLine(float pos_x = 0.0f, float spacing_w = -1.0f); // call between widgets or groups to layout them horizontally
IMGUI_API void Spacing(); // add spacing
IMGUI_API void Dummy(const ImVec2& size); // add a dummy item of given size
IMGUI_API void Indent(); // move content position toward the right by style.IndentSpacing pixels
IMGUI_API void Unindent(); // move content position back to the left (cancel Indent)
IMGUI_API void BeginGroup(); // lock horizontal starting position + capture group bounding box into one "item" (so you can use IsItemHovered() or layout primitives such as SameLine() on whole group, etc.)
IMGUI_API void EndGroup();
IMGUI_API ImVec2 GetCursorPos(); // cursor position is relative to window position
IMGUI_API float GetCursorPosX(); // "
IMGUI_API float GetCursorPosY(); // "
@ -709,7 +709,7 @@ struct ImGuiIO
ImVec2 DisplayVisibleMin; // <unset> (0.0f,0.0f) // If you use DisplaySize as a virtual space larger than your screen, set DisplayVisibleMin/Max to the visible area.
ImVec2 DisplayVisibleMax; // <unset> (0.0f,0.0f) // If the values are the same, we defaults to Min=(0.0f) and Max=DisplaySize
// Advanced/subtle behaviors
// Advanced/subtle behaviors
bool WordMovementUsesAltKey; // = defined(__APPLE__) // OS X style: Text editing cursor movement using Alt instead of Ctrl
bool ShortcutsUseSuperKey; // = defined(__APPLE__) // OS X style: Shortcuts using Cmd/Super instead of Ctrl
bool DoubleClickSelectsWord; // = defined(__APPLE__) // OS X style: Double click selects by word instead of selecting whole text
@ -882,8 +882,8 @@ struct ImGuiTextFilter
const char* end() const { return e; }
bool empty() const { return b == e; }
char front() const { return *b; }
static bool isblank(char c) { return c == ' ' || c == '\t'; }
void trim_blanks() { while (b < e && isblank(*b)) b++; while (e > b && isblank(*(e-1))) e--; }
static bool is_blank(char c) { return c == ' ' || c == '\t'; }
void trim_blanks() { while (b < e && is_blank(*b)) b++; while (e > b && is_blank(*(e-1))) e--; }
IMGUI_API void split(char separator, ImVector<TextRange>& out);
};
@ -1142,6 +1142,8 @@ struct ImDrawList
IMGUI_API void AddRect(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F, float thickness = 1.0f); // a: upper-left, b: lower-right
IMGUI_API void AddRectFilled(const ImVec2& a, const ImVec2& b, ImU32 col, float rounding = 0.0f, int rounding_corners = 0x0F); // a: upper-left, b: lower-right
IMGUI_API void AddRectFilledMultiColor(const ImVec2& a, const ImVec2& b, ImU32 col_upr_left, ImU32 col_upr_right, ImU32 col_bot_right, ImU32 col_bot_left);
IMGUI_API void AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness = 1.0f);
IMGUI_API void AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col);
IMGUI_API void AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness = 1.0f);
IMGUI_API void AddTriangleFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col);
IMGUI_API void AddCircle(const ImVec2& centre, float radius, ImU32 col, int num_segments = 12, float thickness = 1.0f);
@ -1183,9 +1185,9 @@ struct ImDrawList
IMGUI_API void PrimRect(const ImVec2& a, const ImVec2& b, ImU32 col); // Axis aligned rectangle (composed of two triangles)
IMGUI_API void PrimRectUV(const ImVec2& a, const ImVec2& b, const ImVec2& uv_a, const ImVec2& uv_b, ImU32 col);
IMGUI_API void PrimQuadUV(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, const ImVec2& uv_a, const ImVec2& uv_b, const ImVec2& uv_c, const ImVec2& uv_d, ImU32 col);
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
inline void PrimWriteVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col){ _VtxWritePtr->pos = pos; _VtxWritePtr->uv = uv; _VtxWritePtr->col = col; _VtxWritePtr++; _VtxCurrentIdx++; }
inline void PrimWriteIdx(ImDrawIdx idx) { *_IdxWritePtr = idx; _IdxWritePtr++; }
inline void PrimVtx(const ImVec2& pos, const ImVec2& uv, ImU32 col) { PrimWriteIdx((ImDrawIdx)_VtxCurrentIdx); PrimWriteVtx(pos, uv, col); }
IMGUI_API void UpdateClipRect();
IMGUI_API void UpdateTextureID();
};
@ -1287,15 +1289,6 @@ struct ImFontAtlas
// ImFontAtlas automatically loads a default embedded font for you when you call GetTexDataAsAlpha8() or GetTexDataAsRGBA32().
struct ImFont
{
// Members: Settings
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
float Scale; // = 1.0f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
ImVec2 DisplayOffset; // = (0.0f,1.0f) // Offset font rendering by xx pixels
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
ImFontConfig* ConfigData; // // Pointer within ImFontAtlas->ConfigData
int ConfigDataCount; //
// Members: Runtime data
struct Glyph
{
ImWchar Codepoint;
@ -1303,13 +1296,23 @@ struct ImFont
float X0, Y0, X1, Y1;
float U0, V0, U1, V1; // Texture coordinates
};
float Ascent, Descent; // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
ImFontAtlas* ContainerAtlas; // What we has been loaded into
ImVector<Glyph> Glyphs;
// Members: Hot ~62/78 bytes
float FontSize; // <user set> // Height of characters, set during loading (don't change after loading)
float Scale; // = 1.f // Base font scale, multiplied by the per-window font scale which you can adjust with SetFontScale()
ImVec2 DisplayOffset; // = (0.f,1.f) // Offset font rendering by xx pixels
ImVector<Glyph> Glyphs; // // All glyphs.
ImVector<float> IndexXAdvance; // // Sparse. Glyphs->XAdvance in a directly indexable way (more cache-friendly, for CalcTextSize functions which are often bottleneck in large UI).
ImVector<short> IndexLookup; // // Sparse. Index glyphs by Unicode code-point.
const Glyph* FallbackGlyph; // == FindGlyph(FontFallbackChar)
float FallbackXAdvance; //
ImVector<float> IndexXAdvance; // Sparse. Glyphs->XAdvance directly indexable (more cache-friendly that reading from Glyphs, for CalcTextSize functions which are often bottleneck in large UI)
ImVector<int> IndexLookup; // Sparse. Index glyphs by Unicode code-point.
float FallbackXAdvance; // == FallbackGlyph->XAdvance
ImWchar FallbackChar; // = '?' // Replacement glyph if one isn't found. Only set via SetFallbackChar()
// Members: Cold ~18/26 bytes
short ConfigDataCount; // ~ 1 // Number of ImFontConfig involved in creating this font. Bigger than 1 when merging multiple font sources into one ImFont.
ImFontConfig* ConfigData; // // Pointer within ContainerAtlas->ConfigData
ImFontAtlas* ContainerAtlas; // // What we has been loaded into
float Ascent, Descent; // // Ascent: distance from top to bottom of e.g. 'A' [0..FontSize]
// Methods
IMGUI_API ImFont();
@ -1325,7 +1328,8 @@ struct ImFont
// 'wrap_width' enable automatic word-wrapping across multiple lines to fit into given width. 0.0f to disable.
IMGUI_API ImVec2 CalcTextSizeA(float size, float max_width, float wrap_width, const char* text_begin, const char* text_end = NULL, const char** remaining = NULL) const; // utf8
IMGUI_API const char* CalcWordWrapPositionA(float scale, const char* text, const char* text_end, float wrap_width) const;
IMGUI_API void RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
IMGUI_API void RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const;
IMGUI_API void RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width = 0.0f, bool cpu_fine_clip = false) const;
};
//---- Include imgui_user.h at the end of imgui.h

View File

@ -268,7 +268,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
if (ImGui::CollapsingHeader("Widgets"))
{
if (ImGui::TreeNode("Tree"))
if (ImGui::TreeNode("Trees"))
{
for (int i = 0; i < 5; i++)
{
@ -412,7 +412,7 @@ void ImGui::ShowTestWindow(bool* p_opened)
for (int i = 0; i < 16; i++)
{
ImGui::PushID(i);
if (ImGui::Selectable("Me", &selected[i], 0, ImVec2(50,50)))
if (ImGui::Selectable("Sailor", &selected[i], 0, ImVec2(50,50)))
{
int x = i % 4, y = i / 4;
if (x > 0) selected[i - 1] ^= 1;

View File

@ -825,6 +825,30 @@ void ImDrawList::AddRectFilledMultiColor(const ImVec2& a, const ImVec2& c, ImU32
PrimWriteVtx(ImVec2(a.x, c.y), uv, col_bot_left);
}
void ImDrawList::AddQuad(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col, float thickness)
{
if ((col >> 24) == 0)
return;
PathLineTo(a);
PathLineTo(b);
PathLineTo(c);
PathLineTo(d);
PathStroke(col, true, thickness);
}
void ImDrawList::AddQuadFilled(const ImVec2& a, const ImVec2& b, const ImVec2& c, const ImVec2& d, ImU32 col)
{
if ((col >> 24) == 0)
return;
PathLineTo(a);
PathLineTo(b);
PathLineTo(c);
PathLineTo(d);
PathFill(col);
}
void ImDrawList::AddTriangle(const ImVec2& a, const ImVec2& b, const ImVec2& c, ImU32 col, float thickness)
{
if ((col >> 24) == 0)
@ -896,14 +920,6 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
IM_ASSERT(font->ContainerAtlas->TexID == _TextureIdStack.back()); // Use high-level ImGui::PushFont() or low-level ImDrawList::PushTextureId() to change font.
// reserve vertices for worse case (over-reserving is useful and easily amortized)
const int char_count = (int)(text_end - text_begin);
const int vtx_count_max = char_count * 4;
const int idx_count_max = char_count * 6;
const int vtx_begin = VtxBuffer.Size;
const int idx_begin = IdxBuffer.Size;
PrimReserve(idx_count_max, vtx_count_max);
ImVec4 clip_rect = _ClipRectStack.back();
if (cpu_fine_clip_rect)
{
@ -912,18 +928,7 @@ void ImDrawList::AddText(const ImFont* font, float font_size, const ImVec2& pos,
clip_rect.z = ImMin(clip_rect.z, cpu_fine_clip_rect->z);
clip_rect.w = ImMin(clip_rect.w, cpu_fine_clip_rect->w);
}
font->RenderText(font_size, pos, col, clip_rect, text_begin, text_end, this, wrap_width, cpu_fine_clip_rect != NULL);
// give back unused vertices
// FIXME-OPT: clean this up
VtxBuffer.resize((int)(_VtxWritePtr - VtxBuffer.Data));
IdxBuffer.resize((int)(_IdxWritePtr - IdxBuffer.Data));
int vtx_unused = vtx_count_max - (VtxBuffer.Size - vtx_begin);
int idx_unused = idx_count_max - (IdxBuffer.Size - idx_begin);
CmdBuffer.back().ElemCount -= idx_unused;
_VtxWritePtr -= vtx_unused;
_IdxWritePtr -= idx_unused;
_VtxCurrentIdx = (unsigned int)VtxBuffer.Size;
font->RenderText(this, font_size, pos, col, clip_rect, text_begin, text_end, wrap_width, cpu_fine_clip_rect != NULL);
}
void ImDrawList::AddText(const ImVec2& pos, ImU32 col, const char* text_begin, const char* text_end)
@ -1206,7 +1211,7 @@ ImFont* ImFontAtlas::AddFontFromMemoryCompressedTTF(const void* compressed_ttf_d
ImFontConfig font_cfg = font_cfg_template ? *font_cfg_template : ImFontConfig();
IM_ASSERT(font_cfg.FontData == NULL);
font_cfg.FontDataOwnedByAtlas = true;
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, font_cfg_template, glyph_ranges);
return AddFontFromMemoryTTF(buf_decompressed_data, (int)buf_decompressed_size, size_pixels, &font_cfg, glyph_ranges);
}
ImFont* ImFontAtlas::AddFontFromMemoryCompressedBase85TTF(const char* compressed_ttf_data_base85, float size_pixels, const ImFontConfig* font_cfg, const ImWchar* glyph_ranges)
@ -1672,6 +1677,7 @@ void ImFont::BuildLookupTable()
for (int i = 0; i != Glyphs.Size; i++)
max_codepoint = ImMax(max_codepoint, (int)Glyphs[i].Codepoint);
IM_ASSERT(Glyphs.Size < 32*1024);
IndexXAdvance.clear();
IndexXAdvance.resize(max_codepoint + 1);
IndexLookup.clear();
@ -1679,13 +1685,13 @@ void ImFont::BuildLookupTable()
for (int i = 0; i < max_codepoint + 1; i++)
{
IndexXAdvance[i] = -1.0f;
IndexLookup[i] = -1;
IndexLookup[i] = (short)-1;
}
for (int i = 0; i < Glyphs.Size; i++)
{
int codepoint = (int)Glyphs[i].Codepoint;
IndexXAdvance[codepoint] = Glyphs[i].XAdvance;
IndexLookup[codepoint] = i;
IndexLookup[codepoint] = (short)i;
}
// Create a glyph to handle TAB
@ -1699,7 +1705,7 @@ void ImFont::BuildLookupTable()
tab_glyph.Codepoint = '\t';
tab_glyph.XAdvance *= 4;
IndexXAdvance[(int)tab_glyph.Codepoint] = (float)tab_glyph.XAdvance;
IndexLookup[(int)tab_glyph.Codepoint] = (int)(Glyphs.Size-1);
IndexLookup[(int)tab_glyph.Codepoint] = (short)(Glyphs.Size-1);
}
FallbackGlyph = NULL;
@ -1720,9 +1726,9 @@ const ImFont::Glyph* ImFont::FindGlyph(unsigned short c) const
{
if (c < IndexLookup.Size)
{
const int i = IndexLookup[c];
const short i = IndexLookup[c];
if (i != -1)
return &Glyphs[i];
return &Glyphs.Data[i];
}
return FallbackGlyph;
}
@ -1918,7 +1924,23 @@ ImVec2 ImFont::CalcTextSizeA(float size, float max_width, float wrap_width, cons
return text_size;
}
void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, ImDrawList* draw_list, float wrap_width, bool cpu_fine_clip) const
void ImFont::RenderChar(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, unsigned short c) const
{
if (c == ' ' || c == '\t' || c == '\n' || c == '\r') // Match behavior of RenderText(), those 4 codepoints are hard-coded.
return;
if (const Glyph* glyph = FindGlyph(c))
{
float scale = (size >= 0.0f) ? (size / FontSize) : 1.0f;
pos.x = (float)(int)pos.x + DisplayOffset.x;
pos.y = (float)(int)pos.y + DisplayOffset.y;
ImVec2 pos_tl(pos.x + glyph->X0 * scale, pos.y + glyph->Y0 * scale);
ImVec2 pos_br(pos.x + glyph->X1 * scale, pos.y + glyph->Y1 * scale);
draw_list->PrimReserve(6, 4);
draw_list->PrimRectUV(pos_tl, pos_br, ImVec2(glyph->U0, glyph->V0), ImVec2(glyph->U1, glyph->V1), col);
}
}
void ImFont::RenderText(ImDrawList* draw_list, float size, ImVec2 pos, ImU32 col, const ImVec4& clip_rect, const char* text_begin, const char* text_end, float wrap_width, bool cpu_fine_clip) const
{
if (!text_end)
text_end = text_begin + strlen(text_begin);
@ -1936,14 +1958,22 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
const bool word_wrap_enabled = (wrap_width > 0.0f);
const char* word_wrap_eol = NULL;
ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx;
// Skip non-visible lines
const char* s = text_begin;
if (!word_wrap_enabled && y + line_height < clip_rect.y)
while (s < text_end && *s != '\n') // Fast-forward to next line
s++;
// Reserve vertices for remaining worse case (over-reserving is useful and easily amortized)
const int vtx_count_max = (int)(text_end - s) * 4;
const int idx_count_max = (int)(text_end - s) * 6;
const int idx_expected_size = draw_list->IdxBuffer.Size + idx_count_max;
draw_list->PrimReserve(idx_count_max, vtx_count_max);
ImDrawVert* vtx_write = draw_list->_VtxWritePtr;
ImDrawIdx* idx_write = draw_list->_IdxWritePtr;
unsigned int vtx_current_idx = draw_list->_VtxCurrentIdx;
while (s < text_end)
{
if (word_wrap_enabled)
@ -2012,11 +2042,10 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
if (c != ' ' && c != '\t')
{
// We don't do a second finer clipping test on the Y axis as we've already skipped anything before clip_rect.y and exit once we pass clip_rect.w
float y1 = (float)(y + glyph->Y0 * scale);
float y2 = (float)(y + glyph->Y1 * scale);
float x1 = (float)(x + glyph->X0 * scale);
float x2 = (float)(x + glyph->X1 * scale);
float x1 = x + glyph->X0 * scale;
float x2 = x + glyph->X1 * scale;
float y1 = y + glyph->Y0 * scale;
float y2 = y + glyph->Y1 * scale;
if (x1 <= clip_rect.z && x2 >= clip_rect.x)
{
// Render a character
@ -2075,9 +2104,13 @@ void ImFont::RenderText(float size, ImVec2 pos, ImU32 col, const ImVec4& clip_re
x += char_width;
}
// Give back unused vertices
draw_list->VtxBuffer.resize((int)(vtx_write - draw_list->VtxBuffer.Data));
draw_list->IdxBuffer.resize((int)(idx_write - draw_list->IdxBuffer.Data));
draw_list->CmdBuffer[draw_list->CmdBuffer.Size-1].ElemCount -= (idx_expected_size - draw_list->IdxBuffer.Size);
draw_list->_VtxWritePtr = vtx_write;
draw_list->_VtxCurrentIdx = vtx_current_idx;
draw_list->_IdxWritePtr = idx_write;
draw_list->_VtxCurrentIdx = (unsigned int)draw_list->VtxBuffer.Size;
}
//-----------------------------------------------------------------------------

View File

@ -135,7 +135,7 @@ static inline ImVec2 ImLerp(const ImVec2& a, const ImVec2& b, const ImVec2& t)
static inline float ImLengthSqr(const ImVec2& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y; }
static inline float ImLengthSqr(const ImVec4& lhs) { return lhs.x*lhs.x + lhs.y*lhs.y + lhs.z*lhs.z + lhs.w*lhs.w; }
static inline float ImInvLength(const ImVec2& lhs, float fail_value) { float d = lhs.x*lhs.x + lhs.y*lhs.y; if (d > 0.0f) return 1.0f / sqrtf(d); return fail_value; }
static inline ImVec2 ImRound(ImVec2 v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
static inline ImVec2 ImFloor(ImVec2 v) { return ImVec2((float)(int)v.x, (float)(int)v.y); }
// We call C++ constructor on own allocated memory via the placement "new(ptr) Type()" syntax.
// Defining a custom placement new() with a dummy parameter allows us to bypass including <new> which on some platforms complains when user has disabled exceptions.
@ -231,7 +231,7 @@ struct IMGUI_API ImRect
void Expand(const ImVec2& amount) { Min.x -= amount.x; Min.y -= amount.y; Max.x += amount.x; Max.y += amount.y; }
void Reduce(const ImVec2& amount) { Min.x += amount.x; Min.y += amount.y; Max.x -= amount.x; Max.y -= amount.y; }
void Clip(const ImRect& clip) { if (Min.x < clip.Min.x) Min.x = clip.Min.x; if (Min.y < clip.Min.y) Min.y = clip.Min.y; if (Max.x > clip.Max.x) Max.x = clip.Max.x; if (Max.y > clip.Max.y) Max.y = clip.Max.y; }
void Round() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
void Floor() { Min.x = (float)(int)Min.x; Min.y = (float)(int)Min.y; Max.x = (float)(int)Max.x; Max.y = (float)(int)Max.y; }
ImVec2 GetClosestPoint(ImVec2 p, bool on_edge) const
{
if (!on_edge && Contains(p))
@ -594,8 +594,9 @@ struct IMGUI_API ImGuiDrawContext
struct IMGUI_API ImGuiWindow
{
char* Name;
ImGuiID ID;
ImGuiWindowFlags Flags;
ImGuiID ID; // == ImHash(Name)
ImGuiWindowFlags Flags; // See enum ImGuiWindowFlags_
int IndexWithinParent; // Order within immediate parent window, if we are a child window. Otherwise 0.
ImVec2 PosFloat;
ImVec2 Pos; // Position rounded-up to nearest pixel
ImVec2 Size; // Current size (==SizeFull or collapsed title bar size)
@ -636,8 +637,8 @@ struct IMGUI_API ImGuiWindow
ImGuiStorage StateStorage;
float FontWindowScale; // Scale multiplier per-window
ImDrawList* DrawList;
ImGuiWindow* RootWindow;
ImGuiWindow* RootNonPopupWindow;
ImGuiWindow* RootWindow; // If we are a child window, this is pointing to the first non-child parent window. Else point to ourself.
ImGuiWindow* RootNonPopupWindow; // If we are a child widnow, this is pointing to the first non-child non-popup parent window. Else point to ourself.
// Focus
int FocusIdxAllCounter; // Start at -1 and increase as assigned via FocusItemRegister()
@ -715,6 +716,7 @@ namespace ImGui
IMGUI_API bool ButtonBehavior(const ImRect& bb, ImGuiID id, bool* out_hovered, bool* out_held, ImGuiButtonFlags flags = 0);
IMGUI_API bool ButtonEx(const char* label, const ImVec2& size_arg = ImVec2(0,0), ImGuiButtonFlags flags = 0);
IMGUI_API bool CloseButton(ImGuiID id, const ImVec2& pos, float radius);
IMGUI_API bool SliderBehavior(const ImRect& frame_bb, ImGuiID id, float* v, float v_min, float v_max, float power, int decimal_precision, ImGuiSliderFlags flags = 0);
IMGUI_API bool SliderFloatN(const char* label, float* v, int components, float v_min, float v_max, const char* display_format, float power);

View File

@ -39,7 +39,21 @@
#ifdef __cplusplus
extern "C" {
#endif
//////////////////////////////////////////////////////////////////////////////////////////////////
// Constants not used directly in below API
// This is a GUID/magic value used for when applications pass a path where shader debug
// information can be found to match up with a stripped shader.
// the define can be used like so: const GUID RENDERDOC_ShaderDebugMagicValue = RENDERDOC_ShaderDebugMagicValue_value
#define RENDERDOC_ShaderDebugMagicValue_struct { 0xeab25520, 0x6670, 0x4865, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff }
// as an alternative when you want a byte array (assuming x86 endianness):
#define RENDERDOC_ShaderDebugMagicValue_bytearray { 0x20, 0x55, 0xb2, 0xea, 0x70, 0x66, 0x65, 0x48, 0x84, 0x29, 0x6c, 0x8, 0x51, 0x54, 0x00, 0xff }
// truncated version when only a uint64_t is available (e.g. Vulkan tags):
#define RENDERDOC_ShaderDebugMagicValue_truncated 0x48656670eab25520ULL
//////////////////////////////////////////////////////////////////////////////////////////////////
// RenderDoc capture options
//

View File

@ -1,10 +1,10 @@
[bgfx](https://github.com/bkaradzic/bgfx) - Cross-platform rendering library
============================================================================
[![Join the chat at https://gitter.im/bkaradzic/bgfx](https://badges.gitter.im/bkaradzic/bgfx.svg)](https://gitter.im/bkaradzic/bgfx)
[![Build Status](https://travis-ci.org/bkaradzic/bgfx.svg?branch=master)](https://travis-ci.org/bkaradzic/bgfx)
[![Build status](https://ci.appveyor.com/api/projects/status/ipa3ojgeaet1oko5?svg=true)](https://ci.appveyor.com/project/bkaradzic/bgfx)
[![License](https://img.shields.io/badge/license-BSD--2%20clause-blue.svg)](https://bkaradzic.github.io/bgfx/license.html)
[![Join the chat at https://gitter.im/bkaradzic/bgfx](https://badges.gitter.im/bkaradzic/bgfx.svg)](https://gitter.im/bkaradzic/bgfx)
[What is it?](https://bkaradzic.github.io/bgfx/overview.html)
-------------------------------------------------------------
@ -139,6 +139,14 @@ action puzzle game which isn't afraid of complexity — think Chip's Challenge o
crack.
![blackshift-screenshot](https://img.itch.io/aW1hZ2UvNTA3NDkvMjU2OTIzLmpwZw==/original/V%2BbpZD.jpg)
https://eheitzresearch.wordpress.com/415-2/ - Real-Time Polygonal-Light Shading
with Linearly Transformed Cosines, Eric Heitz, Jonathan Dupuy, Stephen Hill and
David Neubelt, ACM SIGGRAPH 2016
<a href="http://www.youtube.com/watch?feature=player_embedded&v=ZLRgEN7AQgM
" target="_blank"><img src="http://img.youtube.com/vi/ZLRgEN7AQgM/0.jpg"
alt="Real-Time Polygonal-Light Shading with Linearly Transformed Cosines "
width="640" height="480" border="0" /></a>
[License (BSD 2-clause)](https://bkaradzic.github.io/bgfx/license.html)
-----------------------------------------------------------------------

View File

@ -7,6 +7,7 @@
#include "common.h"
#include "bgfx_utils.h"
#include "logo.h"
#include "imgui/imgui.h"
class ExampleHelloWorld : public entry::AppI
{
@ -28,23 +29,111 @@ class ExampleHelloWorld : public entry::AppI
// Set view 0 clear state.
bgfx::setViewClear(0
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0x303030ff
, 0x000000ff
, 1.0f
, 0
);
imguiCreate();
ImGui::GetIO().FontGlobalScale = 1.5;
}
virtual int shutdown() BX_OVERRIDE
{
// Cleanup.
imguiDestroy();
// Shutdown bgfx.
bgfx::shutdown();
return 0;
}
void displayMainMenu()
{
if (ImGui::BeginMainMenuBar())
{
if (ImGui::BeginMenu("Left"))
{
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
ImGui::Separator();
if (ImGui::BeginMenu("Sort mode"))
{
ImGui::MenuItem("Name");
ImGui::MenuItem("Extension");
ImGui::MenuItem("Modif. Time");
ImGui::MenuItem("Size");
ImGui::MenuItem("Unsorted");
ImGui::EndMenu();
}
if (ImGui::MenuItem("Change source")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Files"))
{
if (ImGui::MenuItem("User menu", "F2")) {}
if (ImGui::MenuItem("View", "F3")) {}
if (ImGui::MenuItem("Edit", "F4")) {}
if (ImGui::MenuItem("Copy", "F5")) {}
if (ImGui::MenuItem("Rename or move", "F6")) {}
if (ImGui::MenuItem("Make directory", "F7")) {}
if (ImGui::MenuItem("Delete", "F8")) {}
ImGui::Separator();
if (ImGui::MenuItem("File attributes", "CTRL+A")) {}
if (ImGui::MenuItem("Apply command", "CTRL+G")) {}
ImGui::Separator();
if (ImGui::MenuItem("Select group")) {}
if (ImGui::MenuItem("Unselect group")) {}
if (ImGui::MenuItem("Invert selection")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Commands"))
{
if (ImGui::MenuItem("Find file", "ALT+F7")) {}
if (ImGui::MenuItem("History", "ALT+F8")) {}
if (ImGui::MenuItem("Maximize window", "ALT+F9")) {}
ImGui::Separator();
if (ImGui::MenuItem("Panel on/off", "CTRL+O")) {}
if (ImGui::MenuItem("Equal panels", "CTRL+=")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Options"))
{
if (ImGui::MenuItem("Settings")) {}
ImGui::EndMenu();
}
if (ImGui::BeginMenu("Right"))
{
if (ImGui::MenuItem("Brief", "CTRL+1")) {}
if (ImGui::MenuItem("Medium", "CTRL+2")) {}
if (ImGui::MenuItem("Two columns", "CTRL+3")) {}
if (ImGui::MenuItem("Full (name)", "CTRL+4")) {}
if (ImGui::MenuItem("Full (size, time)", "CTRL+5")) {}
if (ImGui::MenuItem("Full (access)", "CTRL+6")) {}
ImGui::Separator();
if (ImGui::BeginMenu("Sort mode"))
{
ImGui::MenuItem("Name");
ImGui::MenuItem("Extension");
ImGui::MenuItem("Modif. Time");
ImGui::MenuItem("Size");
ImGui::MenuItem("Unsorted");
ImGui::EndMenu();
}
if (ImGui::MenuItem("Change source")) {}
ImGui::EndMenu();
}
ImGui::EndMainMenuBar();
}
}
bool update() BX_OVERRIDE
{
if (!entry::processEvents(m_width, m_height, m_debug, m_reset) )
if (!entry::processEvents(m_width, m_height, m_debug, m_reset, &m_mouseState) )
{
// Set view 0 default viewport.
bgfx::setViewRect(0, 0, 0, m_width, m_height);
@ -53,18 +142,91 @@ class ExampleHelloWorld : public entry::AppI
// if no other draw calls are submitted to view 0.
bgfx::touch(0);
// Use debug font to print information about this example.
bgfx::dbgTextClear();
bgfx::dbgTextImage(bx::uint16_max(m_width /2/8, 20)-20
, bx::uint16_max(m_height/2/16, 6)-6
, 40
, 12
, s_logo
, 160
);
bgfx::dbgTextPrintf(0, 1, 0x4f, "bgfx/examples/00-helloworld");
bgfx::dbgTextPrintf(0, 2, 0x6f, "Description: Initialization and debug text.");
imguiBeginFrame(m_mouseState.m_mx
, m_mouseState.m_my
, (m_mouseState.m_buttons[entry::MouseButton::Left] ? IMGUI_MBUT_LEFT : 0)
| (m_mouseState.m_buttons[entry::MouseButton::Right] ? IMGUI_MBUT_RIGHT : 0)
, m_mouseState.m_mz
, m_width
, m_height
);
displayMainMenu();
ImGui::SetNextWindowPos(ImVec2(0, 32));
ImGui::SetNextWindowSize(ImVec2(m_width/2, m_height - 32));
if (ImGui::Begin("Window1", nullptr, ImVec2(m_width/2, m_height-32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
{
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
ImGui::BeginChild("Sub1", ImVec2(0, m_height - 48), true);
ImGui::Columns(4, "mycolumns");
ImGui::Separator();
ImGui::Text("ID"); ImGui::NextColumn();
ImGui::Text("Name"); ImGui::NextColumn();
ImGui::Text("Path"); ImGui::NextColumn();
ImGui::Text("Flags"); ImGui::NextColumn();
ImGui::Separator();
const char* names[3] = { "One", "Two", "Three" };
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
static int selected = -1;
for (int i = 0; i < 50; i++)
{
char label[32];
sprintf(label, "%04d", i);
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
selected = i;
ImGui::NextColumn();
ImGui::Text(names[i%3]); ImGui::NextColumn();
ImGui::Text(paths[i % 3]); ImGui::NextColumn();
ImGui::Text("...."); ImGui::NextColumn();
}
ImGui::Columns(1);
ImGui::Separator();
ImGui::EndChild();
ImGui::PopStyleVar();
}
ImGui::End();
ImGui::SameLine();
ImGui::SetNextWindowPos(ImVec2(m_width / 2, 32));
ImGui::SetNextWindowSize(ImVec2(m_width / 2, m_height - 32));
if (ImGui::Begin("Window2", nullptr, ImVec2(m_width/2, m_height - 32), 1.0f, ImGuiWindowFlags_NoTitleBar | ImGuiWindowFlags_NoResize | ImGuiWindowFlags_NoMove | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoScrollbar))
{
ImGui::PushStyleVar(ImGuiStyleVar_ChildWindowRounding, 5.0f);
ImGui::BeginChild("Sub2", ImVec2(0, m_height - 48), true);
ImGui::Columns(4, "mycolumns");
ImGui::Separator();
ImGui::Text("ID"); ImGui::NextColumn();
ImGui::Text("Name"); ImGui::NextColumn();
ImGui::Text("Path"); ImGui::NextColumn();
ImGui::Text("Flags"); ImGui::NextColumn();
ImGui::Separator();
const char* names[3] = { "One", "Two", "Three" };
const char* paths[3] = { "/path/one", "/path/two", "/path/three" };
static int selected = -1;
for (int i = 0; i < 3; i++)
{
char label[32];
sprintf(label, "%04d", i);
if (ImGui::Selectable(label, selected == i, ImGuiSelectableFlags_SpanAllColumns))
selected = i;
ImGui::NextColumn();
ImGui::Text(names[i]); ImGui::NextColumn();
ImGui::Text(paths[i]); ImGui::NextColumn();
ImGui::Text("...."); ImGui::NextColumn();
}
ImGui::Columns(1);
ImGui::Separator();
ImGui::EndChild();
ImGui::PopStyleVar();
}
ImGui::End();
imguiEndFrame();
// Advance to next frame. Rendering thread will be kicked to
// process submitted rendering primitives.
bgfx::frame();
@ -79,6 +241,7 @@ class ExampleHelloWorld : public entry::AppI
uint32_t m_height;
uint32_t m_debug;
uint32_t m_reset;
entry::MouseState m_mouseState;
};
ENTRY_IMPLEMENT_MAIN(ExampleHelloWorld);

View File

@ -163,10 +163,10 @@ class ExampleBump : public entry::AppI
m_program = loadProgram(m_instancingSupported ? "vs_bump_instanced" : "vs_bump", "fs_bump");
// Load diffuse texture.
m_textureColor = loadTexture("fieldstone-rgba.dds");
m_textureColor = loadTexture("textures/fieldstone-rgba.dds");
// Load normal texture.
m_textureNormal = loadTexture("fieldstone-n.dds");
m_textureNormal = loadTexture("textures/fieldstone-n.dds");
m_timeOffset = bx::getHPCounter();
}

View File

@ -149,15 +149,15 @@ public:
// Create vertex stream declaration.
PosTexcoordVertex::init();
m_textures[0] = loadTexture("texture_compression_bc1.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
m_textures[1] = loadTexture("texture_compression_bc2.dds", BGFX_TEXTURE_U_CLAMP);
m_textures[2] = loadTexture("texture_compression_bc3.dds", BGFX_TEXTURE_V_CLAMP);
m_textures[3] = loadTexture("texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) );
m_textures[4] = loadTexture("texture_compression_etc2.ktx");
m_textures[5] = loadTexture("texture_compression_ptc12.pvr");
m_textures[6] = loadTexture("texture_compression_ptc14.pvr");
m_textures[7] = loadTexture("texture_compression_ptc22.pvr");
m_textures[8] = loadTexture("texture_compression_ptc24.pvr");
m_textures[0] = loadTexture("textures/texture_compression_bc1.dds", BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP);
m_textures[1] = loadTexture("textures/texture_compression_bc2.dds", BGFX_TEXTURE_U_CLAMP);
m_textures[2] = loadTexture("textures/texture_compression_bc3.dds", BGFX_TEXTURE_V_CLAMP);
m_textures[3] = loadTexture("textures/texture_compression_etc1.ktx", BGFX_TEXTURE_U_BORDER|BGFX_TEXTURE_V_BORDER|BGFX_TEXTURE_BORDER_COLOR(1) );
m_textures[4] = loadTexture("textures/texture_compression_etc2.ktx");
m_textures[5] = loadTexture("textures/texture_compression_ptc12.pvr");
m_textures[6] = loadTexture("textures/texture_compression_ptc14.pvr");
m_textures[7] = loadTexture("textures/texture_compression_ptc22.pvr");
m_textures[8] = loadTexture("textures/texture_compression_ptc24.pvr");
const bgfx::Caps* caps = bgfx::getCaps();
m_texture3DSupported = !!(caps->supported & BGFX_CAPS_TEXTURE_3D);

View File

@ -178,7 +178,7 @@ class ExampleHDR : public entry::AppI
bgfx::setViewName(8, "Blur vertical");
bgfx::setViewName(9, "Blur horizontal + tonemap");
m_uffizi = loadTexture("uffizi.dds"
m_uffizi = loadTexture("textures/uffizi.dds"
, 0
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP

View File

@ -54,8 +54,8 @@ class ExampleLod : public entry::AppI
m_program = loadProgram("vs_tree", "fs_tree");
m_textureLeafs = loadTexture("leafs1.dds");
m_textureBark = loadTexture("bark1.dds");
m_textureLeafs = loadTexture("textures/leafs1.dds");
m_textureBark = loadTexture("textures/bark1.dds");
const bgfx::Memory* stippleTex = bgfx::alloc(8*4);
memset(stippleTex->data, 0, stippleTex->size);

View File

@ -873,9 +873,9 @@ int _main_(int _argc, char** _argv)
hplaneMesh.load(s_hplaneVertices, BX_COUNTOF(s_hplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) );
vplaneMesh.load(s_vplaneVertices, BX_COUNTOF(s_vplaneVertices), PosNormalTexcoordVertex::ms_decl, s_planeIndices, BX_COUNTOF(s_planeIndices) );
bgfx::TextureHandle figureTex = loadTexture("figure-rgba.dds");
bgfx::TextureHandle flareTex = loadTexture("flare.dds");
bgfx::TextureHandle fieldstoneTex = loadTexture("fieldstone-rgba.dds");
bgfx::TextureHandle figureTex = loadTexture("textures/figure-rgba.dds");
bgfx::TextureHandle flareTex = loadTexture("textures/flare.dds");
bgfx::TextureHandle fieldstoneTex = loadTexture("textures/fieldstone-rgba.dds");
// Setup lights.
const float rgbInnerR[][4] =

View File

@ -1878,9 +1878,9 @@ int _main_(int _argc, char** _argv)
s_uniforms.init();
s_uniforms.submitConstUniforms();
bgfx::TextureHandle figureTex = loadTexture("figure-rgba.dds");
bgfx::TextureHandle flareTex = loadTexture("flare.dds");
bgfx::TextureHandle fieldstoneTex = loadTexture("fieldstone-rgba.dds");
bgfx::TextureHandle figureTex = loadTexture("textures/figure-rgba.dds");
bgfx::TextureHandle flareTex = loadTexture("textures/flare.dds");
bgfx::TextureHandle fieldstoneTex = loadTexture("textures/fieldstone-rgba.dds");
bgfx::TextureHandle fbtextures[] =
{

View File

@ -1379,9 +1379,9 @@ int _main_(int _argc, char** _argv)
PosColorTexCoord0Vertex::init();
// Textures.
bgfx::TextureHandle texFigure = loadTexture("figure-rgba.dds");
bgfx::TextureHandle texFlare = loadTexture("flare.dds");
bgfx::TextureHandle texFieldstone = loadTexture("fieldstone-rgba.dds");
bgfx::TextureHandle texFigure = loadTexture("textures/figure-rgba.dds");
bgfx::TextureHandle texFlare = loadTexture("textures/flare.dds");
bgfx::TextureHandle texFieldstone = loadTexture("textures/fieldstone-rgba.dds");
// Meshes.
Mesh bunnyMesh;

View File

@ -156,12 +156,10 @@ struct LightProbe
{
char filePath[512];
strcpy(filePath, _name);
strcat(filePath, "_lod.dds");
bx::snprintf(filePath, BX_COUNTOF(filePath), "textures/%s_lod.dds", _name);
m_tex = loadTexture(filePath, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP);
strcpy(filePath, _name);
strcat(filePath, "_irr.dds");
bx::snprintf(filePath, BX_COUNTOF(filePath), "textures/%s_irr.dds", _name);
m_texIrr = loadTexture(filePath, BGFX_TEXTURE_U_CLAMP|BGFX_TEXTURE_V_CLAMP|BGFX_TEXTURE_W_CLAMP);
}

View File

@ -293,10 +293,10 @@ class ExampleDeferred : public entry::AppI
m_lineProgram = loadProgram("vs_deferred_debug_line", "fs_deferred_debug_line");
// Load diffuse texture.
m_textureColor = loadTexture("fieldstone-rgba.dds");
m_textureColor = loadTexture("textures/fieldstone-rgba.dds");
// Load normal texture.
m_textureNormal = loadTexture("fieldstone-n.dds");
m_textureNormal = loadTexture("textures/fieldstone-n.dds");
m_gbufferTex[0].idx = bgfx::invalidHandle;
m_gbufferTex[1].idx = bgfx::invalidHandle;

View File

@ -33,26 +33,16 @@ const float DEFAULT_BRIGHTNESS = 1.0f;
const int TEXTURE_SIZE = 64;
const int HALF_TEXTURE_SIZE = TEXTURE_SIZE / 2;
struct PosColorUvVertex
void PosColorUvVertex::init()
{
float m_x;
float m_y;
float m_z;
float m_u;
float m_v;
uint32_t m_abgr;
ms_decl
.begin()
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
.end();
}
static void init()
{
ms_decl
.begin()
.add(bgfx::Attrib::Position, 3, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
.end();
}
static bgfx::VertexDecl ms_decl;
};
bgfx::VertexDecl PosColorUvVertex::ms_decl;
inline float normalizef(float _a)
@ -156,7 +146,7 @@ void VectorDisplay::endFrame()
bgfx::updateDynamicVertexBuffer(m_vertexBuffers[m_currentDrawStep]
, 0
, bgfx::copy(m_points.data(), (uint32_t)m_points.size() * sizeof(point_t) )
, bgfx::copy(m_points.data(), (uint32_t)m_points.size() * sizeof(PosColorUvVertex) )
);
m_vertexBuffersSize[m_currentDrawStep] = (uint32_t)m_points.size();
@ -307,7 +297,7 @@ void VectorDisplay::beginDraw(float _x, float _y)
{
BX_CHECK(0 == m_pendingPoints.size(), "Begin draw on already filled buffer!");
pending_point_t point;
PendingPoint point;
point.x = _x * m_drawScale + m_drawOffsetX;
point.y = _y * m_drawScale + m_drawOffsetY;
m_pendingPoints.push_back(point);
@ -315,7 +305,7 @@ void VectorDisplay::beginDraw(float _x, float _y)
void VectorDisplay::drawTo(float _x, float _y)
{
pending_point_t point;
PendingPoint point;
point.x = _x * m_drawScale + m_drawOffsetX;
point.y = _y * m_drawScale + m_drawOffsetY;
m_pendingPoints.push_back(point);
@ -331,7 +321,7 @@ void VectorDisplay::endDraw()
// from the list of points, build a list of lines
uint32_t nlines = (uint32_t)m_pendingPoints.size() - 1;
line_t* lines = (line_t*)alloca(nlines * sizeof(line_t) );
Line* lines = (Line*)alloca(nlines * sizeof(Line) );
float t = effectiveThickness();
int first_last_same = bx::fabsolute(m_pendingPoints[0].x - m_pendingPoints[m_pendingPoints.size() - 1].x) < 0.1
@ -340,7 +330,7 @@ void VectorDisplay::endDraw()
// compute basics
for (size_t i = 1; i < m_pendingPoints.size(); i++)
{
line_t* line = &lines[i - 1];
Line* line = &lines[i - 1];
line->is_first = i == 1;
line->is_last = i == nlines;
@ -370,7 +360,7 @@ void VectorDisplay::endDraw()
// compute adjustments for connected line segments
for (size_t i = 0; i < nlines; i++)
{
line_t* line = &lines[i], * pline = &lines[(nlines + i - 1) % nlines];
Line* line = &lines[i], * pline = &lines[(nlines + i - 1) % nlines];
if (line->has_prev)
{
@ -428,7 +418,7 @@ void VectorDisplay::endDraw()
// compute line geometry
for (size_t i = 0; i < nlines; i++)
{
line_t* line = &lines[i];
Line* line = &lines[i];
// shorten lines if needed
line->x0 = line->x0 + line->s0 * line->cos_a;
@ -592,13 +582,13 @@ void VectorDisplay::setDrawColor(float _r, float _g, float _b, float _a)
void VectorDisplay::appendTexpoint(float _x, float _y, float _u, float _v)
{
point_t point;
point.x = _x;
point.y = _y;
point.z = 0.0;
point.color = (m_drawColorA << 24) | (m_drawColorB << 16) | (m_drawColorG << 8) | m_drawColorR;
point.u = _u / TEXTURE_SIZE;
point.v = 1.0f - _v / TEXTURE_SIZE;
PosColorUvVertex point;
point.m_x = _x;
point.m_y = _y;
point.m_z = 0.0;
point.m_abgr = (m_drawColorA << 24) | (m_drawColorB << 16) | (m_drawColorG << 8) | m_drawColorR;
point.m_u = _u / TEXTURE_SIZE;
point.m_v = 1.0f - _v / TEXTURE_SIZE;
m_points.push_back(point);
}
@ -638,14 +628,14 @@ void VectorDisplay::drawFan(float _cx, float _cy, float _pa, float _a, float _t,
}
}
void VectorDisplay::drawLines(line_t* _lines, int _numberLines)
void VectorDisplay::drawLines(Line* _lines, int _numberLines)
{
int i;
float t = effectiveThickness();
for (i = 0; i < _numberLines; i++)
{
line_t* line = &_lines[i], * pline = &_lines[(_numberLines + i - 1) % _numberLines];
Line* line = &_lines[i], * pline = &_lines[(_numberLines + i - 1) % _numberLines];
if (line->has_prev) // draw fan for connection to previous
{

View File

@ -18,6 +18,19 @@
#include <tinystl/vector.h>
namespace stl = tinystl;
struct PosColorUvVertex
{
float m_x;
float m_y;
float m_z;
float m_u;
float m_v;
uint32_t m_abgr;
static void init();
static bgfx::VertexDecl ms_decl;
};
class VectorDisplay
{
public:
@ -103,19 +116,12 @@ public:
protected:
void screenSpaceQuad(float _textureWidth, float _textureHeight, float _width = 1.0f, float _height = 1.0f);
typedef struct //has to match the spec submitted to the 3d-api!
{
float x, y, z;
float u, v;
uint32_t color;
} point_t;
typedef struct
struct PendingPoint
{
float x, y;
} pending_point_t;
};
typedef struct
struct Line
{
float x0, y0, x1, y1; // nominal points
float a; // angle
@ -135,7 +141,7 @@ protected:
float s0, s1; // shorten line by this amount
float len;
} line_t;
};
float effectiveThickness();
void setupResDependent();
@ -144,7 +150,7 @@ protected:
void appendTexpoint(float _x, float _y, float _u, float _v);
void drawFan(float _cx, float _cy, float _pa, float _a, float _t, float _s, float _e);
void drawLines(line_t* _lines, int _numberLines);
void drawLines(Line* _lines, int _numberLines);
void genLinetex();
bool m_originBottomLeft;
@ -170,8 +176,8 @@ protected:
float m_decayValue;
uint8_t m_drawColorR, m_drawColorG, m_drawColorB, m_drawColorA;
stl::vector<point_t> m_points;
stl::vector<pending_point_t> m_pendingPoints;
stl::vector<PosColorUvVertex> m_points;
stl::vector<PendingPoint> m_pendingPoints;
int m_currentDrawStep;
stl::vector<bgfx::DynamicVertexBufferHandle> m_vertexBuffers;

View File

@ -156,28 +156,20 @@ bgfx::ProgramHandle loadProgram(const char* _vsName, const char* _fsName)
typedef unsigned char stbi_uc;
extern "C" stbi_uc *stbi_load_from_memory(stbi_uc const *buffer, int len, int *x, int *y, int *comp, int req_comp);
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _name, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info)
bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _filePath, uint32_t _flags, uint8_t _skip, bgfx::TextureInfo* _info)
{
char filePath[512] = { '\0' };
if (NULL == strchr(_name, '/') )
if (NULL != bx::stristr(_filePath, ".dds")
|| NULL != bx::stristr(_filePath, ".pvr")
|| NULL != bx::stristr(_filePath, ".ktx") )
{
strcpy(filePath, "textures/");
}
strcat(filePath, _name);
if (NULL != bx::stristr(_name, ".dds")
|| NULL != bx::stristr(_name, ".pvr")
|| NULL != bx::stristr(_name, ".ktx") )
{
const bgfx::Memory* mem = loadMem(_reader, filePath);
const bgfx::Memory* mem = loadMem(_reader, _filePath);
if (NULL != mem)
{
return bgfx::createTexture(mem, _flags, _skip, _info);
}
bgfx::TextureHandle handle = BGFX_INVALID_HANDLE;
DBG("Failed to load %s.", filePath);
DBG("Failed to load %s.", _filePath);
return handle;
}
@ -185,7 +177,7 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _name, uin
bx::AllocatorI* allocator = entry::getAllocator();
uint32_t size = 0;
void* data = loadMem(_reader, allocator, filePath, &size);
void* data = loadMem(_reader, allocator, _filePath, &size);
if (NULL != data)
{
int width = 0;
@ -222,7 +214,7 @@ bgfx::TextureHandle loadTexture(bx::FileReaderI* _reader, const char* _name, uin
}
else
{
DBG("Failed to load %s.", filePath);
DBG("Failed to load %s.", _filePath);
}
return handle;

View File

@ -463,8 +463,8 @@ BX_PRAGMA_DIAGNOSTIC_POP();
case Event::Gamepad:
{
const GamepadEvent* gev = static_cast<const GamepadEvent*>(ev);
DBG("gamepad %d, %d", gev->m_gamepad.idx, gev->m_connected);
// const GamepadEvent* gev = static_cast<const GamepadEvent*>(ev);
// DBG("gamepad %d, %d", gev->m_gamepad.idx, gev->m_connected);
}
break;

View File

@ -49,6 +49,25 @@ namespace entry
return modifiers;
}
static uint8_t translateKeyModifierPress(uint16_t _key)
{
uint8_t modifier;
switch (_key)
{
case SDL_SCANCODE_LALT: { modifier = Modifier::LeftAlt; } break;
case SDL_SCANCODE_RALT: { modifier = Modifier::RightAlt; } break;
case SDL_SCANCODE_LCTRL: { modifier = Modifier::LeftCtrl; } break;
case SDL_SCANCODE_RCTRL: { modifier = Modifier::RightCtrl; } break;
case SDL_SCANCODE_LSHIFT: { modifier = Modifier::LeftShift; } break;
case SDL_SCANCODE_RSHIFT: { modifier = Modifier::RightShift; } break;
case SDL_SCANCODE_LGUI: { modifier = Modifier::LeftMeta; } break;
case SDL_SCANCODE_RGUI: { modifier = Modifier::RightMeta; } break;
default: { modifier = 0; } break;
}
return modifier;
}
static uint8_t s_translateKey[256];
static void initTranslateKey(uint16_t _sdl, Key::Enum _key)
@ -307,8 +326,15 @@ namespace entry
initTranslateKey(SDL_SCANCODE_END, Key::End);
initTranslateKey(SDL_SCANCODE_PRINTSCREEN, Key::Print);
initTranslateKey(SDL_SCANCODE_KP_PLUS, Key::Plus);
initTranslateKey(SDL_SCANCODE_EQUALS, Key::Plus);
initTranslateKey(SDL_SCANCODE_KP_MINUS, Key::Minus);
initTranslateKey(SDL_SCANCODE_MINUS, Key::Minus);
initTranslateKey(SDL_SCANCODE_GRAVE, Key::Tilde);
initTranslateKey(SDL_SCANCODE_KP_COMMA, Key::Comma);
initTranslateKey(SDL_SCANCODE_COMMA, Key::Comma);
initTranslateKey(SDL_SCANCODE_KP_PERIOD, Key::Period);
initTranslateKey(SDL_SCANCODE_PERIOD, Key::Period);
initTranslateKey(SDL_SCANCODE_SLASH, Key::Slash);
initTranslateKey(SDL_SCANCODE_F1, Key::F1);
initTranslateKey(SDL_SCANCODE_F2, Key::F2);
initTranslateKey(SDL_SCANCODE_F3, Key::F3);
@ -532,29 +558,43 @@ namespace entry
uint8_t modifiers = translateKeyModifiers(kev.keysym.mod);
Key::Enum key = translateKey(kev.keysym.scancode);
// TODO: These keys are not captured by SDL_TEXTINPUT. Should be probably handled by SDL_TEXTEDITING. This is a workaround for now.
if (key == 1) // Escape
#if 0
DBG("SDL scancode %d, key %d, name %s, key name %s"
, kev.keysym.scancode
, key
, SDL_GetScancodeName(kev.keysym.scancode)
, SDL_GetKeyName(kev.keysym.scancode)
);
#endif // 0
/// If you only press (e.g.) 'shift' and nothing else, then key == 'shift', modifier == 0.
/// Further along, pressing 'shift' + 'ctrl' would be: key == 'shift', modifier == 'ctrl.
if (0 == key && 0 == modifiers)
{
modifiers = translateKeyModifierPress(kev.keysym.scancode);
}
/// TODO: These keys are not captured by SDL_TEXTINPUT. Should be probably handled by SDL_TEXTEDITING. This is a workaround for now.
if (Key::Esc == key)
{
uint8_t pressedChar[4];
pressedChar[0] = 0x1b;
m_eventQueue.postCharEvent(handle, 1, pressedChar);
}
else if (key == 2) // Enter
else if (Key::Return == key)
{
uint8_t pressedChar[4];
pressedChar[0] = 0x0d;
m_eventQueue.postCharEvent(handle, 1, pressedChar);
}
else if (key == 5) // Backspace
else if (Key::Backspace == key)
{
uint8_t pressedChar[4];
pressedChar[0] = 0x08;
m_eventQueue.postCharEvent(handle, 1, pressedChar);
}
else
{
m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED);
}
m_eventQueue.postKeyEvent(handle, key, modifiers, kev.state == SDL_PRESSED);
}
}
break;

View File

@ -115,15 +115,15 @@ private:
m_windowVisible = args->Visible;
}
void OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
void OnSuspending(Platform::Object^ sender, SuspendingEventArgs^ args)
{
SuspendingDeferral^ deferral = args->SuspendingOperation->GetDeferral();
BX_UNUSED(deferral);
}
}
void OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
}
void OnResuming(Platform::Object^ sender, Platform::Object^ args)
{
}
void OnWindowClosed(CoreWindow^ sender, CoreWindowEventArgs^ args)
{

View File

@ -16,9 +16,9 @@
#include <tinystl/unordered_map.h>
namespace stl = tinystl;
struct Mouse
struct InputMouse
{
Mouse()
InputMouse()
: m_width(1280)
, m_height(720)
, m_wheelDelta(120)
@ -69,10 +69,10 @@ struct Mouse
bool m_lock;
};
struct Keyboard
struct InputKeyboard
{
Keyboard()
: m_ring(BX_COUNTOF(m_char) )
InputKeyboard()
: m_ring(BX_COUNTOF(m_char)-4)
{
}
@ -215,7 +215,7 @@ struct Input
for (const InputBinding* binding = _bindings; binding->m_key != entry::Key::None; ++binding)
{
uint8_t modifiers;
bool down = Keyboard::decodeKeyState(m_keyboard.m_key[binding->m_key], modifiers);
bool down = InputKeyboard::decodeKeyState(m_keyboard.m_key[binding->m_key], modifiers);
if (binding->m_flags == 1)
{
@ -278,8 +278,8 @@ struct Input
typedef stl::unordered_map<stl::string, const InputBinding*> InputBindingMap;
InputBindingMap m_inputBindingsMap;
Mouse m_mouse;
Keyboard m_keyboard;
InputKeyboard m_keyboard;
InputMouse m_mouse;
Gamepad m_gamepad[ENTRY_CONFIG_MAX_GAMEPADS];
};

View File

@ -273,6 +273,11 @@ namespace ImGui
return ImageButton(_handle, IMGUI_FLAGS_ALPHA_BLEND, 0, _size, _uv0, _uv1, _framePadding, _bgCol, _tintCol);
}
inline void NextLine()
{
SetCursorPosY(GetCursorPosY() + GetTextLineHeightWithSpacing() );
}
} // namespace ImGui
#endif // IMGUI_H_HEADER_GUARD

View File

@ -6,7 +6,7 @@
#ifndef BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_DEFINES_H_HEADER_GUARD
#define BGFX_API_VERSION UINT32_C(13)
#define BGFX_API_VERSION UINT32_C(14)
///
#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) //!< Enable RGB write.
@ -296,6 +296,7 @@
#define BGFX_TEXTURE_MIP_POINT UINT32_C(0x00000400) //!<
#define BGFX_TEXTURE_MIP_SHIFT 10 //!<
#define BGFX_TEXTURE_MIP_MASK UINT32_C(0x00000400) //!<
#define BGFX_TEXTURE_MSAA_SAMPLE UINT32_C(0x00000800) //!<
#define BGFX_TEXTURE_RT UINT32_C(0x00001000) //!<
#define BGFX_TEXTURE_RT_MSAA_X2 UINT32_C(0x00002000) //!<
#define BGFX_TEXTURE_RT_MSAA_X4 UINT32_C(0x00003000) //!<

View File

@ -278,7 +278,8 @@ typedef struct bgfx_hmd_eye
float rotation[4];
float translation[3];
float fov[4];
float adjust[3];
float viewOffset[3];
float projection[16];
float pixelsPerTanAngle[2];
} bgfx_hmd_eye_t;
@ -298,10 +299,12 @@ typedef struct bgfx_hmd
/**/
typedef struct bgfx_stats
{
uint64_t cpuTime;
uint64_t cpuTimeBegin;
uint64_t cpuTimeEnd;
uint64_t cpuTimerFreq;
uint64_t gpuTime;
uint64_t gpuTimeBegin;
uint64_t gpuTimeEnd;
uint64_t gpuTimerFreq;
} bgfx_stats_t;

View File

@ -324,18 +324,22 @@ EXE=.exe
endif
geometryc: .build/projects/$(BUILD_PROJECT_DIR) ## Build geometryc tool.
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) -f geometryc.make config=$(BUILD_TOOLS_CONFIG)
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) geometryc config=$(BUILD_TOOLS_CONFIG)
$(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/geometryc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/geometryc$(EXE)
shaderc: .build/projects/$(BUILD_PROJECT_DIR) ## Build shaderc tool.
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) -f shaderc.make config=$(BUILD_TOOLS_CONFIG)
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) shaderc config=$(BUILD_TOOLS_CONFIG)
$(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/shaderc$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/shaderc$(EXE)
texturec: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturec tool.
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) -f texturec.make config=$(BUILD_TOOLS_CONFIG)
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturec config=$(BUILD_TOOLS_CONFIG)
$(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturec$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturec$(EXE)
tools: geometryc shaderc texturec ## Build tools.
texturev: .build/projects/$(BUILD_PROJECT_DIR) ## Build texturev tool.
$(SILENT) $(MAKE) -C .build/projects/$(BUILD_PROJECT_DIR) texturev config=$(BUILD_TOOLS_CONFIG)
$(SILENT) cp .build/$(BUILD_OUTPUT_DIR)/bin/texturev$(BUILD_TOOLS_SUFFIX)$(EXE) tools/bin/$(OS)/texturev$(EXE)
tools: geometryc shaderc texturec texturev ## Build tools.
dist-windows: .build/projects/gmake-mingw-gcc
$(SILENT) $(MAKE) -C .build/projects/gmake-mingw-gcc config=release64 -j 6 geometryc

View File

@ -19,6 +19,7 @@ project ("example-common")
path.join(BGFX_DIR, "3rdparty/ocornut-imgui/**.cpp"),
path.join(BGFX_DIR, "3rdparty/ocornut-imgui/**.h"),
path.join(BGFX_DIR, "examples/common/**.cpp"),
path.join(BGFX_DIR, "examples/common/**.cpp"),
path.join(BGFX_DIR, "examples/common/**.h"),
}
@ -60,7 +61,7 @@ project ("example-common")
"ENTRY_CONFIG_USE_GLFW=1",
}
end
configuration { "linux-steamlink" }
defines {
"EGL_API_FB",
@ -71,7 +72,10 @@ project ("example-common")
path.join(BGFX_DIR, "examples/common/**.mm"),
}
configuration { "winphone8* or winstore8*"}
configuration { "winphone8* or winstore8* or durango"}
files {
path.join(BGFX_DIR, "examples/common/**.cx"),
}
linkoptions {
"/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
}

View File

@ -65,8 +65,9 @@ solution "bgfx"
language "C++"
startproject "example-00-helloworld"
BGFX_DIR = path.getabsolute("..")
BX_DIR = os.getenv("BX_DIR")
MODULE_DIR = path.getabsolute("../")
BGFX_DIR = path.getabsolute("..")
BX_DIR = os.getenv("BX_DIR")
local BGFX_BUILD_DIR = path.join(BGFX_DIR, ".build")
local BGFX_THIRD_PARTY_DIR = path.join(BGFX_DIR, "3rdparty")
@ -405,5 +406,6 @@ if _OPTIONS["with-tools"] then
group "tools"
dofile "shaderc.lua"
dofile "texturec.lua"
dofile "texturev.lua"
dofile "geometryc.lua"
end

233
3rdparty/bgfx/scripts/texturev.lua vendored Normal file
View File

@ -0,0 +1,233 @@
project ("texturev")
uuid (os.uuid("texturev") )
kind "ConsoleApp"
configuration {}
includedirs {
path.join(BX_DIR, "include"),
path.join(BGFX_DIR, "include"),
path.join(BGFX_DIR, "3rdparty"),
path.join(BGFX_DIR, "examples/common"),
path.join(MODULE_DIR, "include"),
path.join(MODULE_DIR, "3rdparty"),
path.join(MODULE_DIR, "src"),
}
files {
path.join(MODULE_DIR, "tools/texturev/**"),
}
links {
"example-common",
"bgfx",
}
if _OPTIONS["with-sdl"] then
defines { "ENTRY_CONFIG_USE_SDL=1" }
links { "SDL2" }
configuration { "x32", "windows" }
libdirs { "$(SDL2_DIR)/lib/x86" }
configuration { "x64", "windows" }
libdirs { "$(SDL2_DIR)/lib/x64" }
configuration {}
end
if _OPTIONS["with-glfw"] then
defines { "ENTRY_CONFIG_USE_GLFW=1" }
links {
"glfw3"
}
configuration { "linux or freebsd" }
links {
"Xrandr",
"Xinerama",
"Xi",
"Xxf86vm",
"Xcursor",
}
configuration { "osx" }
linkoptions {
"-framework CoreVideo",
"-framework IOKit",
}
configuration {}
end
if _OPTIONS["with-ovr"] then
links {
"winmm",
"ws2_32",
}
-- Check for LibOVR 5.0+
if os.isdir(path.join(os.getenv("OVR_DIR"), "LibOVR/Lib/Windows/Win32/Debug/VS2012")) then
configuration { "x32", "Debug" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Debug", _ACTION) }
configuration { "x32", "Release" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/Win32/Release", _ACTION) }
configuration { "x64", "Debug" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Debug", _ACTION) }
configuration { "x64", "Release" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Windows/x64/Release", _ACTION) }
configuration { "x32 or x64" }
links { "libovr" }
else
configuration { "x32" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/Win32", _ACTION) }
configuration { "x64" }
libdirs { path.join("$(OVR_DIR)/LibOVR/Lib/x64", _ACTION) }
configuration { "x32", "Debug" }
links { "libovrd" }
configuration { "x32", "Release" }
links { "libovr" }
configuration { "x64", "Debug" }
links { "libovr64d" }
configuration { "x64", "Release" }
links { "libovr64" }
end
configuration {}
end
configuration { "vs*" }
linkoptions {
"/ignore:4199", -- LNK4199: /DELAYLOAD:*.dll ignored; no imports found from *.dll
}
links { -- this is needed only for testing with GLES2/3 on Windows with VS2008
"DelayImp",
}
configuration { "vs201*" }
linkoptions { -- this is needed only for testing with GLES2/3 on Windows with VS201x
"/DELAYLOAD:\"libEGL.dll\"",
"/DELAYLOAD:\"libGLESv2.dll\"",
}
configuration { "mingw*" }
targetextension ".exe"
configuration { "vs20* or mingw*" }
links {
"gdi32",
"psapi",
}
configuration { "winphone8*"}
removelinks {
"DelayImp",
"gdi32",
"psapi"
}
links {
"d3d11",
"dxgi"
}
linkoptions {
"/ignore:4264" -- LNK4264: archiving object file compiled with /ZW into a static library; note that when authoring Windows Runtime types it is not recommended to link with a static library that contains Windows Runtime metadata
}
-- WinRT targets need their own output directories are build files stomp over each other
targetdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "bin", _name))
objdir (path.join(BGFX_BUILD_DIR, "arm_" .. _ACTION, "obj", _name))
configuration { "mingw-clang" }
kind "ConsoleApp"
configuration { "android*" }
kind "ConsoleApp"
targetextension ".so"
linkoptions {
"-shared",
}
links {
"EGL",
"GLESv2",
}
configuration { "nacl*" }
kind "ConsoleApp"
targetextension ".nexe"
links {
"ppapi",
"ppapi_gles2",
"pthread",
}
configuration { "pnacl" }
kind "ConsoleApp"
targetextension ".pexe"
links {
"ppapi",
"ppapi_gles2",
"pthread",
}
configuration { "asmjs" }
kind "ConsoleApp"
targetextension ".bc"
configuration { "linux-* or freebsd" }
links {
"X11",
"GL",
"pthread",
}
configuration { "rpi" }
links {
"X11",
"GLESv2",
"EGL",
"bcm_host",
"vcos",
"vchiq_arm",
"pthread",
}
configuration { "osx" }
linkoptions {
"-framework Cocoa",
"-framework Metal",
"-framework QuartzCore",
"-framework OpenGL",
}
configuration { "ios*" }
kind "ConsoleApp"
linkoptions {
"-framework CoreFoundation",
"-framework Foundation",
"-framework OpenGLES",
"-framework UIKit",
"-framework QuartzCore",
}
configuration { "xcode4", "ios" }
kind "WindowedApp"
configuration { "qnx*" }
targetextension ""
links {
"EGL",
"GLESv2",
}
configuration {}
strip()

View File

@ -10,6 +10,7 @@
#include "glcontext_wgl.cpp"
#include "image.cpp"
#include "hmd_ovr.cpp"
#include "hmd_openvr.cpp"
#include "debug_renderdoc.cpp"
#include "renderer_d3d9.cpp"
#include "renderer_d3d11.cpp"

View File

@ -3657,11 +3657,17 @@ BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT);
BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) )
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Transform, bgfx_transform_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::HMD::Eye, bgfx_hmd_eye_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::HMD, bgfx_hmd_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Stats, bgfx_stats_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::VertexDecl, bgfx_vertex_decl_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientIndexBuffer, bgfx_transient_index_buffer_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TransientVertexBuffer, bgfx_transient_vertex_buffer_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InstanceDataBuffer, bgfx_instance_data_buffer_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::TextureInfo, bgfx_texture_info_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Attachment, bgfx_attachment_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps::GPU, bgfx_caps_gpu_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Caps, bgfx_caps_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::PlatformData, bgfx_platform_data_t);
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::InternalData, bgfx_internal_data_t);

View File

@ -2385,7 +2385,10 @@ namespace bgfx
}
uint32_t offset = (dib.m_startIndex + _startIndex)*indexSize;
uint32_t size = bx::uint32_min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size);
uint32_t size = bx::uint32_min(offset
+ bx::uint32_min(bx::uint32_satsub(dib.m_size, _startIndex*indexSize), _mem->size)
, BGFX_CONFIG_DYNAMIC_INDEX_BUFFER_SIZE) - offset
;
BX_CHECK(_mem->size <= size, "Truncating dynamic index buffer update (size %d, mem size %d)."
, size
, _mem->size
@ -2535,9 +2538,12 @@ namespace bgfx
}
uint32_t offset = (dvb.m_startVertex + _startVertex)*dvb.m_stride;
uint32_t size = bx::uint32_min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size);
uint32_t size = bx::uint32_min(offset
+ bx::uint32_min(bx::uint32_satsub(dvb.m_size, _startVertex*dvb.m_stride), _mem->size)
, BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE) - offset
;
BX_CHECK(_mem->size <= size, "Truncating dynamic vertex buffer update (size %d, mem size %d)."
, dvb.m_size
, size
, _mem->size
);

View File

@ -128,7 +128,6 @@ struct BgfxSamplerCube
struct BgfxSampler2DMS
{
SamplerState m_sampler;
Texture2DMS<vec4> m_texture;
};
@ -240,11 +239,9 @@ vec4 bgfxTexelFetch(BgfxSampler3D _sampler, ivec3 _coord, int _lod)
# define texture2DProj(_sampler, _coord) bgfxTexture2DProj(_sampler, _coord)
# define SAMPLER2DMS(_name, _reg) \
uniform SamplerState _name ## Sampler : register(s[_reg]); \
uniform Texture2DMS _name ## Texture : register(t[_reg]); \
static BgfxSampler2DMS _name = { _name ## Sampler, _name ## Texture }
uniform Texture2DMS<vec4> _name ## Texture : register(t[_reg]); \
static BgfxSampler2DMS _name = { _name ## Texture }
# define sampler2DMS BgfxSampler2DMS
# define texture2DMS(_sampler, _coord, _idx) bgfxTexture2DMS(_sampler, _coord, _idx)
# define SAMPLER2DSHADOW(_name, _reg) \
uniform SamplerComparisonState _name ## Sampler : register(s[_reg]); \

View File

@ -487,6 +487,7 @@ GL_IMPORT_OES__(true, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D);
GL_IMPORT_EXT__(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D);
GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample);
GL_IMPORT_EXT__(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
GL_IMPORT_EXT__(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);
@ -567,6 +568,7 @@ GL_IMPORT______(true, PFNGLCOMPRESSEDTEXSUBIMAGE3DPROC, glCompressedT
GL_IMPORT______(true, PFNGLTEXSTORAGE2DPROC, glTexStorage2D);
GL_IMPORT______(true, PFNGLTEXSTORAGE3DPROC, glTexStorage3D);
GL_IMPORT______(true, PFNGLTEXIMAGE2DMULTISAMPLEPROC, glTexImage2DMultisample);
GL_IMPORT______(true, PFNGLINSERTEVENTMARKEREXTPROC, glInsertEventMarker);
GL_IMPORT______(true, PFNGLPUSHGROUPMARKEREXTPROC, glPushGroupMarker);

View File

@ -60,14 +60,14 @@ namespace bgfx
VR_GetVRInitErrorAsEnglishDescription = (PFN_VR_GETVRINITERRORASENGLISHDESCRIPTION)bx::dlsym(openvrdll, "VR_GetVRInitErrorAsEnglishDescription");
if (NULL == VR_InitInternal
&& NULL == VR_ShutdownInternal
&& NULL == VR_IsHmdPresent
&& NULL == VR_GetGenericInterface
&& NULL == VR_IsRuntimeInstalled
&& NULL == VR_IsInterfaceVersionValid
&& NULL == VR_GetInitToken
&& NULL == VR_GetVRInitErrorAsSymbol
&& NULL == VR_GetVRInitErrorAsEnglishDescription)
|| NULL == VR_ShutdownInternal
|| NULL == VR_IsHmdPresent
|| NULL == VR_GetGenericInterface
|| NULL == VR_IsRuntimeInstalled
|| NULL == VR_IsInterfaceVersionValid
|| NULL == VR_GetInitToken
|| NULL == VR_GetVRInitErrorAsSymbol
|| NULL == VR_GetVRInitErrorAsEnglishDescription)
{
bx::dlclose(openvrdll);
return NULL;

View File

@ -248,9 +248,9 @@ namespace bgfx
}
}
eye.viewOffset[0] = erd.HmdToEyeOffset.x;
eye.viewOffset[1] = erd.HmdToEyeOffset.y;
eye.viewOffset[2] = erd.HmdToEyeOffset.z;
eye.viewOffset[0] = -erd.HmdToEyeOffset.x;
eye.viewOffset[1] = -erd.HmdToEyeOffset.y;
eye.viewOffset[2] = -erd.HmdToEyeOffset.z;
eye.pixelsPerTanAngle[0] = erd.PixelsPerTanAngleAtCenter.x;
eye.pixelsPerTanAngle[1] = erd.PixelsPerTanAngleAtCenter.y;

View File

@ -936,7 +936,7 @@ namespace bgfx { namespace d3d11
;
hr = E_FAIL;
for (uint32_t ii = 0; ii < 3 && FAILED(hr);)
for (uint32_t ii = 0; ii < BX_COUNTOF(featureLevel) && FAILED(hr);)
{
hr = D3D11CreateDevice(m_adapter
, m_driverType
@ -995,9 +995,11 @@ namespace bgfx { namespace d3d11
if (NULL == m_deviceCtx)
{
BX_TRACE("Unable to create Direct3D11 device.");
BX_TRACE("Unable to retrieve Direct3D11 ImmediateContext.");
goto error;
}
m_featureLevel = m_device->GetFeatureLevel();
}
{
@ -2408,7 +2410,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
#if !BX_PLATFORM_WINDOWS
HRESULT hr;
HRESULT hr = S_OK;
if (g_platformData.ndt == 0)
{
hr = m_factory->CreateSwapChainForCoreWindow(m_device
@ -3076,14 +3078,20 @@ BX_PRAGMA_DIAGNOSTIC_POP();
ID3D11ShaderResourceView* srv;
if (NULL == ptr)
{
TextureD3D11& texture = m_textures[_handle.idx];
const TextureD3D11& texture = m_textures[_handle.idx];
const bool msaaSample = 0 != (texture.m_flags&BGFX_TEXTURE_MSAA_SAMPLE);
const uint32_t msaaQuality = bx::uint32_satsub( (texture.m_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT, 1);
const DXGI_SAMPLE_DESC& msaa = s_msaa[msaaQuality];
D3D11_SHADER_RESOURCE_VIEW_DESC desc;
desc.Format = s_textureFormat[texture.m_textureFormat].m_fmtSrv;
switch (texture.m_type)
{
case TextureD3D11::Texture2D:
desc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
desc.ViewDimension = 1 < msaa.Count && msaaSample
? D3D11_SRV_DIMENSION_TEXTURE2DMS
: D3D11_SRV_DIMENSION_TEXTURE2D
;
desc.Texture2D.MostDetailedMip = _mip;
desc.Texture2D.MipLevels = 1;
break;
@ -3762,6 +3770,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
m_mirrorTextureDesc.Height = _height;
ovrResult result = ovr_CreateMirrorTextureDX(_session, s_renderD3D11->m_device, &m_mirrorTextureDesc, &m_mirrorTexture);
BX_WARN(OVR_SUCCESS(result), "Could not create D3D11 OVR mirror texture");
BX_UNUSED(result);
}
void OVRMirrorD3D11::destroy(const ovrSession& session)
@ -4324,6 +4333,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
const bool srgb = 0 != (m_flags&BGFX_TEXTURE_SRGB) || imageContainer.m_srgb;
const bool blit = 0 != (m_flags&BGFX_TEXTURE_BLIT_DST);
const bool readBack = 0 != (m_flags&BGFX_TEXTURE_READ_BACK);
const bool msaaSample = 0 != (m_flags&BGFX_TEXTURE_MSAA_SAMPLE);
const uint32_t msaaQuality = bx::uint32_satsub( (m_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT, 1);
const DXGI_SAMPLE_DESC& msaa = s_msaa[msaaQuality];
@ -4400,8 +4410,16 @@ BX_PRAGMA_DIAGNOSTIC_POP();
{
desc.ArraySize = 1;
desc.MiscFlags = 0;
srvd.ViewDimension = 1 < msaa.Count ? D3D11_SRV_DIMENSION_TEXTURE2DMS : D3D11_SRV_DIMENSION_TEXTURE2D;
srvd.Texture2D.MipLevels = numMips;
if (1 < msaa.Count
&& msaaSample)
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2DMS;
}
else
{
srvd.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
srvd.Texture2D.MipLevels = numMips;
}
}
DX_CHECK(s_renderD3D11->m_device->CreateTexture2D(&desc, kk == 0 ? NULL : srd, &m_texture2d) );
@ -4675,7 +4693,7 @@ BX_PRAGMA_DIAGNOSTIC_POP();
}
}
const uint32_t msaaQuality = bx::uint32_satsub( (texture.m_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT, 1);
const uint32_t msaaQuality = bx::uint32_satsub( (texture.m_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT, 1);
const DXGI_SAMPLE_DESC& msaa = s_msaa[msaaQuality];
if (isDepth( (TextureFormat::Enum)texture.m_textureFormat) )

View File

@ -352,6 +352,7 @@ namespace bgfx { namespace d3d12
_commandList->ResourceBarrier(1, &barrier);
}
#if USE_D3D12_DYNAMIC_LIB
static const GUID IID_ID3D12CommandAllocator = { 0x6102dee4, 0xaf59, 0x4b09, { 0xb9, 0x99, 0xb4, 0x4d, 0x73, 0xf0, 0x9b, 0x24 } };
static const GUID IID_ID3D12CommandQueue = { 0x0ec870a6, 0x5d7e, 0x4c22, { 0x8c, 0xfc, 0x5b, 0xaa, 0xe0, 0x76, 0x16, 0xed } };
static const GUID IID_ID3D12CommandSignature = { 0xc36a797c, 0xec80, 0x4f0a, { 0x89, 0x85, 0xa7, 0xb2, 0x47, 0x50, 0x82, 0xd1 } };
@ -366,6 +367,7 @@ namespace bgfx { namespace d3d12
static const GUID IID_ID3D12RootSignature = { 0xc54a6b66, 0x72df, 0x4ee8, { 0x8b, 0xe5, 0xa9, 0x46, 0xa1, 0x42, 0x92, 0x14 } };
static const GUID IID_ID3D12QueryHeap = { 0x0d9658ae, 0xed45, 0x469e, { 0xa6, 0x1d, 0x97, 0x0e, 0xc5, 0x83, 0xca, 0xb4 } };
static const GUID IID_IDXGIFactory4 = { 0x1bc6ea02, 0xef36, 0x464f, { 0xbf, 0x0c, 0x21, 0xca, 0x39, 0xe5, 0x16, 0x8a } };
#endif // USE_D3D12_DYNAMIC_LIB
struct HeapProperty
{
@ -578,6 +580,7 @@ namespace bgfx { namespace d3d12
m_adapter = NULL;
m_driverType = D3D_DRIVER_TYPE_HARDWARE;
if (NULL != m_factory)
{
#if BX_PLATFORM_WINDOWS
IDXGIAdapter3* adapter;
@ -674,6 +677,7 @@ namespace bgfx { namespace d3d12
goto error;
}
if (NULL != m_factory)
{
memset(&m_adapterDesc, 0, sizeof(m_adapterDesc) );
luid = m_device->GetAdapterLuid();
@ -726,6 +730,36 @@ namespace bgfx { namespace d3d12
}
}
#if !BX_PLATFORM_WINDOWS
if (NULL == m_factory)
{
IDXGIDevice1* dxgiDevice;
hr = m_device->QueryInterface(IID_IDXGIDevice1, (void**)&dxgiDevice);
if (FAILED(hr) )
{
BX_TRACE("Unable to query IDXGIDevice1 interface 0x%08x.", hr);
goto error;
}
hr = dxgiDevice->GetAdapter(&m_adapter);
if (FAILED(hr) )
{
BX_TRACE("DXGIDevice1::GetAdapter failed 0x%08x.", hr);
goto error;
}
hr = m_adapter->GetParent(IID_IDXGIFactory2, (void**)&m_factory);
if (FAILED(hr) )
{
BX_TRACE("IDXGIAdapter::GetParent failed 0x%08x.", hr);
goto error;
}
}
#endif // !BX_PLATFORM_WINDOWS
DX_CHECK(m_device->CheckFeatureSupport(D3D12_FEATURE_D3D12_OPTIONS, &m_options, sizeof(m_options) ) );
BX_TRACE("D3D12 options:")
BX_TRACE("\tTiledResourcesTier %d", m_options.TiledResourcesTier);
@ -738,34 +772,96 @@ namespace bgfx { namespace d3d12
m_cmd.init(m_device);
errorState = ErrorState::CreatedCommandQueue;
m_scd.BufferDesc.Width = BGFX_DEFAULT_WIDTH;
m_scd.BufferDesc.Height = BGFX_DEFAULT_HEIGHT;
m_scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_scd.BufferDesc.Scaling = DXGI_MODE_SCALING_STRETCHED;
m_scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
m_scd.BufferDesc.RefreshRate.Numerator = 60;
m_scd.BufferDesc.RefreshRate.Denominator = 1;
m_scd.SampleDesc.Count = 1;
m_scd.SampleDesc.Quality = 0;
m_scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
m_scd.BufferCount = bx::uint32_min(BX_COUNTOF(m_backBufferColor), 4);
m_scd.OutputWindow = (HWND)g_platformData.nwh;
m_scd.Windowed = true;
m_scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
m_scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
BX_CHECK(m_scd.BufferCount <= BX_COUNTOF(m_backBufferColor), "Swap chain buffer count %d (max %d)."
, m_scd.BufferCount
, BX_COUNTOF(m_backBufferColor)
);
hr = m_factory->CreateSwapChain(m_cmd.m_commandQueue
, &m_scd
, reinterpret_cast<IDXGISwapChain**>(&m_swapChain)
);
BX_WARN(SUCCEEDED(hr), "Failed to create swap chain.");
if (FAILED(hr) )
if (NULL == g_platformData.backBuffer)
{
goto error;
#if !BX_PLATFORM_WINDOWS
hr = m_adapter->GetParent(__uuidof(IDXGIFactory2), (void**)&m_factory);
DX_RELEASE(m_adapter, 1);
if (FAILED(hr) )
{
BX_TRACE("Unable to create Direct3D11 device.");
goto error;
}
m_scd.Width = BGFX_DEFAULT_WIDTH;
m_scd.Height = BGFX_DEFAULT_HEIGHT;
m_scd.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_scd.Stereo = false;
m_scd.SampleDesc.Count = 1;
m_scd.SampleDesc.Quality = 0;
m_scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
m_scd.BufferCount = bx::uint32_min(BX_COUNTOF(m_backBufferColor), 4);
m_scd.Scaling = DXGI_SCALING_STRETCH;
m_scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
m_scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
if (NULL == g_platformData.ndt)
{
hr = m_factory->CreateSwapChainForCoreWindow(m_device
, (::IUnknown*)g_platformData.nwh
, &m_scd
, NULL
, &m_swapChain
);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to create Direct3D11 swap chain.");
}
else
{
BGFX_FATAL(g_platformData.ndt == reinterpret_cast<void*>(1), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
hr = m_factory->CreateSwapChainForComposition(m_device
, &m_scd
, NULL
, &m_swapChain
);
BX_WARN(SUCCEEDED(hr), "Unable to create Direct3D11 swap chain.");
# if BX_PLATFORM_WINRT
IInspectable* nativeWindow = reinterpret_cast<IInspectable *>(g_platformData.nwh);
ISwapChainBackgroundPanelNative* panel = NULL;
hr = nativeWindow->QueryInterface(__uuidof(ISwapChainBackgroundPanelNative), (void**)&panel);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
if (NULL != panel)
{
hr = panel->SetSwapChain(m_swapChain);
BGFX_FATAL(SUCCEEDED(hr), Fatal::UnableToInitialize, "Unable to set swap chain on panel.");
panel->Release();
}
# endif // BX_PLATFORM_WINRT
}
#else
m_scd.BufferDesc.Width = BGFX_DEFAULT_WIDTH;
m_scd.BufferDesc.Height = BGFX_DEFAULT_HEIGHT;
m_scd.BufferDesc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
m_scd.BufferDesc.Scaling = DXGI_MODE_SCALING_STRETCHED;
m_scd.BufferDesc.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
m_scd.BufferDesc.RefreshRate.Numerator = 60;
m_scd.BufferDesc.RefreshRate.Denominator = 1;
m_scd.SampleDesc.Count = 1;
m_scd.SampleDesc.Quality = 0;
m_scd.BufferUsage = DXGI_USAGE_RENDER_TARGET_OUTPUT;
m_scd.BufferCount = bx::uint32_min(BX_COUNTOF(m_backBufferColor), 4);
m_scd.OutputWindow = (HWND)g_platformData.nwh;
m_scd.Windowed = true;
m_scd.SwapEffect = DXGI_SWAP_EFFECT_FLIP_SEQUENTIAL;
m_scd.Flags = DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH;
BX_CHECK(m_scd.BufferCount <= BX_COUNTOF(m_backBufferColor), "Swap chain buffer count %d (max %d)."
, m_scd.BufferCount
, BX_COUNTOF(m_backBufferColor)
);
hr = m_factory->CreateSwapChain(m_cmd.m_commandQueue
, &m_scd
, reinterpret_cast<IDXGISwapChain**>(&m_swapChain)
);
#endif // BX_PLATFORM_*
if (FAILED(hr) )
{
BX_TRACE("Failed to create swap chain.");
goto error;
}
}
m_presentElapsed = 0;
@ -1537,8 +1633,8 @@ namespace bgfx { namespace d3d12
void blitSetup(TextVideoMemBlitter& _blitter) BX_OVERRIDE
{
const uint32_t width = m_scd.BufferDesc.Width;
const uint32_t height = m_scd.BufferDesc.Height;
const uint32_t width = getBufferWidth();
const uint32_t height = getBufferHeight();
FrameBufferHandle fbh = BGFX_INVALID_HANDLE;
setFrameBuffer(fbh, false);
@ -1732,7 +1828,7 @@ namespace bgfx { namespace d3d12
D3D12_FEATURE_DATA_MULTISAMPLE_QUALITY_LEVELS data;
memset(&data, 0, sizeof(msaa) );
data.Format = m_scd.BufferDesc.Format;
data.Format = getBufferFormat();
data.SampleCount = msaa;
data.Flags = D3D12_MULTISAMPLE_QUALITY_LEVELS_FLAG_NONE;
HRESULT hr = m_device->CheckFeatureSupport(D3D12_FEATURE_MULTISAMPLE_QUALITY_LEVELS, &data, sizeof(data) );
@ -1793,8 +1889,7 @@ data.NumQualityLevels = 0;
m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
m_textVideoMem.clear();
m_scd.BufferDesc.Width = _resolution.m_width;
m_scd.BufferDesc.Height = _resolution.m_height;
setBufferSize(_resolution.m_width, _resolution.m_height);
preReset();
@ -1824,12 +1919,14 @@ data.NumQualityLevels = 0;
DX_RELEASE(m_swapChain, 0);
#if BX_PLATFORM_WINDOWS
HRESULT hr;
hr = m_factory->CreateSwapChain(m_cmd.m_commandQueue
, &m_scd
, reinterpret_cast<IDXGISwapChain**>(&m_swapChain)
);
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain.");
#endif // BX_PLATFORM_WINDOWS
}
postReset();
@ -2462,6 +2559,44 @@ data.NumQualityLevels = 0;
return _visible == (0 != _render->m_occlusion[_handle.idx]);
}
DXGI_FORMAT getBufferFormat()
{
#if BX_PLATFORM_WINDOWS
return m_scd.BufferDesc.Format;
#else
return m_scd.Format;
#endif
}
uint32_t getBufferWidth()
{
#if BX_PLATFORM_WINDOWS
return m_scd.BufferDesc.Width;
#else
return m_scd.Width;
#endif
}
uint32_t getBufferHeight()
{
#if BX_PLATFORM_WINDOWS
return m_scd.BufferDesc.Height;
#else
return m_scd.Height;
#endif
}
void setBufferSize(uint32_t _width, uint32_t _height)
{
#if BX_PLATFORM_WINDOWS
m_scd.BufferDesc.Width = _width;
m_scd.BufferDesc.Height = _height;
#else
m_scd.Width = _width;
m_scd.Height = _height;
#endif
}
void commit(UniformBuffer& _uniformBuffer)
{
_uniformBuffer.reset();
@ -2614,8 +2749,8 @@ data.NumQualityLevels = 0;
}
else
{
width = m_scd.BufferDesc.Width;
height = m_scd.BufferDesc.Height;
width = getBufferWidth();
height = getBufferHeight();
}
if (0 == _rect.m_x
@ -2711,7 +2846,11 @@ data.NumQualityLevels = 0;
Resolution m_resolution;
bool m_wireframe;
#if BX_PLATFORM_WINDOWS
DXGI_SWAP_CHAIN_DESC m_scd;
#else
DXGI_SWAP_CHAIN_DESC1 m_scd;
#endif // BX_PLATFORM_WINDOWS
uint32_t m_maxAnisotropy;
bool m_depthClamp;
@ -3539,7 +3678,7 @@ data.NumQualityLevels = 0;
DXGI_FORMAT format;
uint32_t stride;
D3D12_RESOURCE_FLAGS flags = needUav
uint32_t flags = needUav
? D3D12_RESOURCE_FLAG_ALLOW_UNORDERED_ACCESS
: D3D12_RESOURCE_FLAG_NONE
;
@ -3602,7 +3741,7 @@ data.NumQualityLevels = 0;
ID3D12Device* device = s_renderD3D12->m_device;
ID3D12GraphicsCommandList* commandList = s_renderD3D12->m_commandList;
m_ptr = createCommittedResource(device, HeapProperty::Default, _size, flags);
m_ptr = createCommittedResource(device, HeapProperty::Default, _size, D3D12_RESOURCE_FLAGS(flags) );
m_gpuVA = m_ptr->GetGPUVirtualAddress();
setState(commandList, drawIndirect
? D3D12_RESOURCE_STATE_INDIRECT_ARGUMENT

View File

@ -918,6 +918,23 @@ namespace bgfx { namespace gl
NULL
};
static const char* s_ARB_gpu_shader5[] =
{
"bitfieldReverse",
"floatBitsToInt",
"floatBitsToUint",
"intBitsToFloat",
"uintBitsToFloat",
NULL
};
static const char* s_ARB_shading_language_packing[] =
{
"packHalf2x16",
"unpackHalf2x16",
NULL
};
static void GL_APIENTRY stubVertexAttribDivisor(GLuint /*_index*/, GLuint /*_divisor*/)
{
}
@ -3410,7 +3427,6 @@ namespace bgfx { namespace gl
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) );
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR) );
GL_CHECK(glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR) );
GL_CHECK(glTexParameteri(GL_TEXTURE_2D_MULTISAMPLE, GL_TEXTURE_MAX_LEVEL, 0) );
}
}
@ -3580,6 +3596,10 @@ namespace bgfx { namespace gl
GLSL_TYPE(GL_INT_SAMPLER_CUBE);
GLSL_TYPE(GL_UNSIGNED_INT_SAMPLER_CUBE);
GLSL_TYPE(GL_SAMPLER_2D_MULTISAMPLE);
GLSL_TYPE(GL_INT_SAMPLER_2D_MULTISAMPLE);
GLSL_TYPE(GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE);
GLSL_TYPE(GL_SAMPLER_2D_SHADOW);
GLSL_TYPE(GL_IMAGE_1D);
@ -3670,6 +3690,10 @@ namespace bgfx { namespace gl
case GL_SAMPLER_2D_SHADOW:
case GL_SAMPLER_2D_MULTISAMPLE:
case GL_INT_SAMPLER_2D_MULTISAMPLE:
case GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE:
case GL_IMAGE_1D:
case GL_INT_IMAGE_1D:
case GL_UNSIGNED_INT_IMAGE_1D:
@ -3779,6 +3803,8 @@ namespace bgfx { namespace gl
GL_CHECK(glBindFragDataLocation(m_id, 0, "bgfx_FragColor") );
#endif // BGFX_CONFIG_RENDERER_OPENGL >= 31
GLint max0, max1;
bool piqSupported = true
&& s_extension[Extension::ARB_program_interface_query ].m_supported
&& s_extension[Extension::ARB_shader_storage_buffer_object].m_supported
@ -3789,16 +3815,18 @@ namespace bgfx { namespace gl
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_ACTIVE_RESOURCES, &activeAttribs ) );
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_ACTIVE_RESOURCES, &activeUniforms) );
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_BUFFER_VARIABLE, GL_ACTIVE_RESOURCES, &activeBuffers ) );
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_PROGRAM_INPUT, GL_MAX_NAME_LENGTH, &max0 ) );
GL_CHECK(glGetProgramInterfaceiv(m_id, GL_UNIFORM, GL_MAX_NAME_LENGTH, &max1 ) );
}
else
{
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTES, &activeAttribs ) );
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORMS, &activeUniforms) );
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) );
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) );
}
GLint max0, max1;
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_ATTRIBUTE_MAX_LENGTH, &max0) );
GL_CHECK(glGetProgramiv(m_id, GL_ACTIVE_UNIFORM_MAX_LENGTH, &max1) );
uint32_t maxLength = bx::uint32_max(max0, max1);
char* name = (char*)alloca(maxLength + 1);
@ -3807,9 +3835,26 @@ namespace bgfx { namespace gl
for (int32_t ii = 0; ii < activeAttribs; ++ii)
{
GLint size;
GLenum type;
GLenum type = 0;
GL_CHECK(glGetActiveAttrib(m_id, ii, maxLength + 1, NULL, &size, &type, name) );
if (piqSupported)
{
GL_CHECK(glGetProgramResourceName(m_id, GL_PROGRAM_INPUT, ii, maxLength + 1, &size, name) );
GLenum typeProp[] = { GL_TYPE };
GL_CHECK(glGetProgramResourceiv(m_id
, GL_PROGRAM_INPUT
, ii
, BX_COUNTOF(typeProp)
, typeProp
, 1
, NULL
, (GLint *)&type)
);
}
else
{
GL_CHECK(glGetActiveAttrib(m_id, ii, maxLength + 1, NULL, &size, &type, name) );
}
BX_TRACE("\t%s %s is at location %d"
, glslTypeName(type)
@ -4130,17 +4175,22 @@ namespace bgfx { namespace gl
m_vcref.invalidate(s_renderGL->m_vaoStateCache);
}
static void texImage(GLenum _target, GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLsizei _depth, GLint _border, GLenum _format, GLenum _type, const GLvoid* _data)
static void texImage(GLenum _target, uint32_t _msaaQuality, GLint _level, GLint _internalFormat, GLsizei _width, GLsizei _height, GLsizei _depth, GLint _border, GLenum _format, GLenum _type, const GLvoid* _data)
{
if (_target == GL_TEXTURE_3D)
{
GL_CHECK(glTexImage3D(_target, _level, _internalFormat, _width, _height, _depth, _border, _format, _type, _data) );
}
else if (_target == GL_TEXTURE_2D_MULTISAMPLE)
{
GL_CHECK(glTexImage2DMultisample(_target, _msaaQuality, _internalFormat, _width, _height, false) );
}
else
{
BX_UNUSED(_depth);
GL_CHECK(glTexImage2D(_target, _level, _internalFormat, _width, _height, _border, _format, _type, _data) );
}
BX_UNUSED(_msaaQuality, _depth, _border, _data);
}
static void texSubImage(GLenum _target, GLint _level, GLint _xoffset, GLint _yoffset, GLint _zoffset, GLsizei _width, GLsizei _height, GLsizei _depth, GLenum _format, GLenum _type, const GLvoid* _data)
@ -4327,7 +4377,14 @@ namespace bgfx { namespace gl
m_requestedFormat = uint8_t(imageContainer.m_format);
m_textureFormat = uint8_t(getViableTextureFormat(imageContainer) );
GLenum target = GL_TEXTURE_2D;
const bool computeWrite = 0 != (_flags&BGFX_TEXTURE_COMPUTE_WRITE);
const bool srgb = 0 != (_flags&BGFX_TEXTURE_SRGB);
const bool msaaSample = 0 != (_flags&BGFX_TEXTURE_MSAA_SAMPLE);
uint32_t msaaQuality = ( (_flags&BGFX_TEXTURE_RT_MSAA_MASK)>>BGFX_TEXTURE_RT_MSAA_SHIFT);
msaaQuality = bx::uint32_satsub(msaaQuality, 1);
msaaQuality = bx::uint32_min(s_renderGL->m_maxMsaa, msaaQuality == 0 ? 0 : 1<<msaaQuality);
GLenum target = msaaSample ? GL_TEXTURE_2D_MULTISAMPLE : GL_TEXTURE_2D;
if (imageContainer.m_cubeMap)
{
target = GL_TEXTURE_CUBE_MAP;
@ -4348,9 +4405,6 @@ namespace bgfx { namespace gl
return;
}
const bool computeWrite = 0 != (m_flags&BGFX_TEXTURE_COMPUTE_WRITE);
const bool srgb = 0 != (m_flags&BGFX_TEXTURE_SRGB);
target = GL_TEXTURE_CUBE_MAP == m_target ? GL_TEXTURE_CUBE_MAP_POSITIVE_X : m_target;
const GLenum internalFmt = srgb
@ -4440,6 +4494,7 @@ namespace bgfx { namespace gl
}
texImage(target+side
, msaaQuality
, lod
, internalFmt
, width
@ -4475,6 +4530,7 @@ namespace bgfx { namespace gl
else
{
texImage(target+side
, msaaQuality
, lod
, internalFmt
, width
@ -4671,8 +4727,9 @@ namespace bgfx { namespace gl
if (hash != m_currentSamplerHash)
{
const GLenum target = m_target;
const uint8_t numMips = m_numMips;
const GLenum target = m_target == GL_TEXTURE_2D_MULTISAMPLE ? GL_TEXTURE_2D : m_target;
const GLenum targetMsaa = m_target;
const uint8_t numMips = m_numMips;
GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_S, s_textureAddress[(flags&BGFX_TEXTURE_U_MASK)>>BGFX_TEXTURE_U_SHIFT]) );
GL_CHECK(glTexParameteri(target, GL_TEXTURE_WRAP_T, s_textureAddress[(flags&BGFX_TEXTURE_V_MASK)>>BGFX_TEXTURE_V_SHIFT]) );
@ -4680,7 +4737,7 @@ namespace bgfx { namespace gl
if (BX_ENABLED(BGFX_CONFIG_RENDERER_OPENGL || BGFX_CONFIG_RENDERER_OPENGLES >= 30)
|| s_extension[Extension::APPLE_texture_max_level].m_supported)
{
GL_CHECK(glTexParameteri(target, GL_TEXTURE_MAX_LEVEL, numMips-1) );
GL_CHECK(glTexParameteri(targetMsaa, GL_TEXTURE_MAX_LEVEL, numMips-1) );
}
if (target == GL_TEXTURE_3D)
@ -4715,12 +4772,12 @@ namespace bgfx { namespace gl
const uint32_t cmpFunc = (flags&BGFX_TEXTURE_COMPARE_MASK)>>BGFX_TEXTURE_COMPARE_SHIFT;
if (0 == cmpFunc)
{
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_MODE, GL_NONE) );
GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_NONE) );
}
else
{
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE) );
GL_CHECK(glTexParameteri(m_target, GL_TEXTURE_COMPARE_FUNC, s_cmpFunc[cmpFunc]) );
GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE) );
GL_CHECK(glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, s_cmpFunc[cmpFunc]) );
}
}
@ -5027,10 +5084,11 @@ namespace bgfx { namespace gl
;
const bool usesIUsamplers = !!bx::findIdentifierMatch(code, s_uisamplers);
const bool usesTexelFetch = !!bx::findIdentifierMatch(code, s_texelFetch);
const bool usesTextureMS = !!bx::findIdentifierMatch(code, s_ARB_texture_multisample);
const bool usesGpuShader5 = !!bx::findIdentifierMatch(code, s_ARB_gpu_shader5);
const bool usesPacking = !!bx::findIdentifierMatch(code, s_ARB_shading_language_packing);
uint32_t version =
usesIUsamplers || usesTexelFetch || usesTextureMS ? 130
usesIUsamplers || usesTexelFetch ? 130
: usesTextureLod ? 120
: 0
;
@ -5048,9 +5106,14 @@ namespace bgfx { namespace gl
}
}
if (usesTextureMS)
if (usesGpuShader5)
{
writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n");
writeString(&writer, "#extension GL_ARB_gpu_shader5 : enable\n");
}
if (usesPacking)
{
writeString(&writer, "#extension GL_ARB_shading_language_packing : enable\n");
}
if (130 <= version)
@ -5090,6 +5153,18 @@ namespace bgfx { namespace gl
writeString(&writer, "#define gl_FragColor bgfx_FragColor\n");
}
}
else
{
if (m_type == GL_FRAGMENT_SHADER)
{
writeString(&writer, "#define in varying\n");
}
else
{
writeString(&writer, "#define in attribute\n");
writeString(&writer, "#define out varying\n");
}
}
writeString(&writer
, "#define lowp\n"
@ -5168,6 +5243,11 @@ namespace bgfx { namespace gl
}
}
if (!!bx::findIdentifierMatch(code, s_ARB_texture_multisample))
{
writeString(&writer, "#extension GL_ARB_texture_multisample : enable\n");
}
if (0 != fragData)
{
writeStringf(&writer, "out vec4 bgfx_FragData[%d];\n", fragData);

View File

@ -640,6 +640,18 @@ typedef uint64_t GLuint64;
# define GL_UNSIGNED_INT_SAMPLER_CUBE 0x8DD4
#endif // GL_UNSIGNED_INT_SAMPLER_CUBE
#ifndef GL_SAMPLER_2D_MULTISAMPLE
# define GL_SAMPLER_2D_MULTISAMPLE 0x9108
#endif // GL_SAMPLER_2D_MULTISAMPLE
#ifndef GL_INT_SAMPLER_2D_MULTISAMPLE
# define GL_INT_SAMPLER_2D_MULTISAMPLE 0x9109
#endif // GL_INT_SAMPLER_2D_MULTISAMPLE
#ifndef GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
# define GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE 0x910A
#endif // GL_UNSIGNED_INT_SAMPLER_2D_MULTISAMPLE
#ifndef GL_SAMPLER_2D_SHADOW
# define GL_SAMPLER_2D_SHADOW 0x8B62
#endif // GL_SAMPLER_2D_SHADOW
@ -867,6 +879,10 @@ typedef uint64_t GLuint64;
# define GL_DISPATCH_INDIRECT_BUFFER 0x90EE
#endif // GL_DISPATCH_INDIRECT_BUFFER
#ifndef GL_MAX_NAME_LENGTH
# define GL_MAX_NAME_LENGTH 0x92F6
#endif // GL_MAX_NAME_LENGTH
#if BX_PLATFORM_NACL
# include "glcontext_ppapi.h"
#elif BX_PLATFORM_WINDOWS

View File

@ -107,6 +107,7 @@ namespace bgfx
murmur.begin();
murmur.add(m_attributes, sizeof(m_attributes) );
murmur.add(m_offset, sizeof(m_offset) );
murmur.add(m_stride);
m_hash = murmur.end();
}

View File

@ -1653,6 +1653,16 @@ namespace bgfx
preprocessor.writef(
"\n#define __RETURN__ \\\n"
"\t} \\\n"
);
if (hlsl <= 3)
{
// preprocessor.writef(
// "\tgl_Position.xy += u_viewTexel.xy * gl_Position.w; \\\n"
// );
}
preprocessor.writef(
"\treturn _varying_"
);
}

View File

@ -19,6 +19,10 @@
#include <tinyexr/tinyexr.h>
#include <edtaa3/edtaa3func.h>
extern "C" {
#include <iqa.h>
}
#define STB_IMAGE_IMPLEMENTATION
#include <stb/stb_image.c>
@ -348,6 +352,7 @@ void help(const char* _error = NULL)
" -m, --mips Generate mip-maps.\n"
" -n, --normalmap Input texture is normal map.\n"
" --sdf <edge> Compute SDF texture.\n"
" --iqa Image Quality Assesment\n"
"\n"
"For additional information, see https://github.com/bkaradzic/bgfx\n"
@ -409,8 +414,9 @@ int main(int _argc, const char* _argv[])
}
}
const bool mips = cmdLine.hasArg('m', "mips");
const bool normalMap = cmdLine.hasArg('n', "normalmap");
const bool mips = cmdLine.hasArg('m', "mips");
const bool normalMap = cmdLine.hasArg('n', "normalmap");
const bool iqa = cmdLine.hasArg('\0', "iqa");
uint32_t size = (uint32_t)bx::getSize(&reader);
const bgfx::Memory* mem = bgfx::alloc(size);
@ -567,6 +573,13 @@ int main(int _argc, const char* _argv[])
, mip.m_format
);
void* ref = NULL;
if (iqa)
{
ref = BX_ALLOC(&allocator, size);
memcpy(ref, rgba, size);
}
imageEncodeFromRgba8(output->data, rgba, dstMip.m_width, dstMip.m_height, format);
for (uint8_t lod = 1; lod < numMips; ++lod)
@ -576,6 +589,40 @@ int main(int _argc, const char* _argv[])
uint8_t* data = const_cast<uint8_t*>(dstMip.m_data);
imageEncodeFromRgba8(data, rgba, dstMip.m_width, dstMip.m_height, format);
}
if (NULL != ref)
{
imageDecodeToRgba8(rgba
, output->data
, mip.m_width
, mip.m_height
, mip.m_width*mip.m_bpp/8
, format
);
static const iqa_ssim_args args =
{
0.39f, // alpha
0.731f, // beta
1.12f, // gamma
187, // L
0.025987f, // K1
0.0173f, // K2
1 // factor
};
float result = iqa_ssim( (uint8_t*)ref
, rgba
, mip.m_width
, mip.m_height
, mip.m_width*mip.m_bpp/8
, 0
, &args
);
printf("%f\n", result);
BX_FREE(&allocator, ref);
}
}
BX_FREE(&allocator, temp);

View File

@ -0,0 +1,127 @@
static const uint8_t fs_texture_glsl[315] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x02, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, // Color.......u_pa
0x72, 0x61, 0x6d, 0x73, 0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0x0c, 0x01, 0x00, 0x00, 0x76, 0x61, // rams..........va
0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, // rying highp vec4
0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, // v_color0;.varyi
0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, // ng highp vec2 v_
0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, // texcoord0;.unifo
0x72, 0x6d, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x32, 0x44, 0x20, 0x73, 0x5f, 0x74, // rm sampler2D s_t
0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, // exColor;.uniform
0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x70, 0x61, // highp vec4 u_pa
0x72, 0x61, 0x6d, 0x73, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, // rams;.void main
0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, // ().{. lowp vec4
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, // tmpvar_1;. tmp
0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, // var_1 = texture2
0x44, 0x4c, 0x6f, 0x64, 0x20, 0x20, 0x20, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // DLod (s_texCo
0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // lor, v_texcoord0
0x2c, 0x20, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, // , u_params.x);.
0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, // gl_FragColor =
0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x2a, 0x20, 0x76, 0x5f, 0x63, 0x6f, // (tmpvar_1 * v_co
0x6c, 0x6f, 0x72, 0x30, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // lor0);.}...
};
static const uint8_t fs_texture_dx9[365] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x02, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, // Color0......u_pa
0x72, 0x61, 0x6d, 0x73, 0x12, 0x01, 0x00, 0x00, 0x01, 0x00, 0x40, 0x01, 0x00, 0x03, 0xff, 0xff, // rams......@.....
0xfe, 0xff, 0x2f, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, // ../.CTAB........
0x00, 0x03, 0xff, 0xff, 0x02, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, // ................
0x7c, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, // |...D...........
0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // P.......`.......
0x01, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, // ....l.......s_te
0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0c, 0x00, 0x01, 0x00, 0x01, 0x00, // xColor..........
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, // ........u_params
0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, 0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, // ....ps_3_0.Micro
0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, // soft (R) HLSL Sh
0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, // ader Compiler 10
0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, // .0.10011.16384..
0x51, 0x00, 0x00, 0x05, 0x01, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, // Q..........?....
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, // ................
0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0x90, // ................
0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x90, 0x00, 0x08, 0x0f, 0xa0, 0x05, 0x00, 0x00, 0x03, // ................
0x00, 0x00, 0x07, 0x80, 0x01, 0x00, 0xd0, 0xa0, 0x01, 0x00, 0xc4, 0x90, 0x01, 0x00, 0x00, 0x02, // ................
0x00, 0x00, 0x08, 0x80, 0x00, 0x00, 0x00, 0xa0, 0x5f, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, // ........_.......
0x00, 0x00, 0xe4, 0x80, 0x00, 0x08, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x0f, 0x80, // ................
0x00, 0x00, 0xe4, 0x80, 0x00, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // .............
};
static const uint8_t fs_texture_dx11[444] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x02, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, 0x72, // FSH........u_par
0x61, 0x6d, 0x73, 0x12, 0x00, 0x00, 0x00, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, // ams.......s_texC
0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x8c, 0x01, 0x44, 0x58, 0x42, 0x43, // olor0.......DXBC
0xb9, 0x1c, 0x87, 0x4c, 0x82, 0x98, 0xc2, 0x74, 0x81, 0x9e, 0xa8, 0x24, 0xac, 0xbe, 0xee, 0x7b, // ...L...t...$...{
0x01, 0x00, 0x00, 0x00, 0x8c, 0x01, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, // ............,...
0xa0, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, // ........ISGNl...
0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........P.......
0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, // ................
0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ................
0x01, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........b.......
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, // ................
0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, // SV_POSITION.COLO
0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, // R.TEXCOORD..OSGN
0x2c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, // ,........... ...
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x0f, 0x00, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, // ....SV_TARGET...
0x53, 0x48, 0x44, 0x52, 0xb0, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, // SHDR....@...,...
0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // Y...F. .........
0x5a, 0x00, 0x00, 0x03, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x18, 0x00, 0x04, // Z....`......X...
0x00, 0x70, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, // .p......UU..b...
0xf2, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, // ........b...2...
0x02, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....e.... ......
0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0c, 0xf2, 0x00, 0x10, 0x00, // h.......H.......
0x00, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x7e, 0x10, 0x00, // ....F.......F~..
0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0a, 0x80, 0x20, 0x00, // .....`........ .
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, 0xf2, 0x20, 0x10, 0x00, // ........8.... ..
0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, // ....F.......F...
0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x10, 0x00, // ....>.......
};
static const uint8_t fs_texture_mtl[699] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xac, 0x02, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . float4 v_colo
0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x74, // r0;. float2 v_t
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, // excoord0;.};.str
0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // uct xlatMtlShade
0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // rOutput {. half
0x34, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, // 4 gl_FragColor;.
0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // };.struct xlatMt
0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, // lShaderUniform {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, // . float4 u_para
0x6d, 0x73, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, 0x74, 0x20, // ms;.};.fragment
0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, // xlatMtlShaderOut
0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, // put xlatMtlMain
0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, // (xlatMtlShaderIn
0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, // put _mtl_i [[sta
0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, // ge_in]], constan
0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, // t xlatMtlShaderU
0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, // niform& _mtl_u [
0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x0a, 0x20, 0x20, 0x2c, // [buffer(0)]]. ,
0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x32, 0x64, 0x3c, 0x66, 0x6c, 0x6f, // texture2d<flo
0x61, 0x74, 0x3e, 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, // at> s_texColor [
0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x2c, 0x20, 0x73, // [texture(0)]], s
0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, // ampler _mtlsmp_s
0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x73, 0x61, 0x6d, 0x70, // _texColor [[samp
0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, // ler(0)]]).{. xl
0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, // atMtlShaderOutpu
0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // t _mtl_o;. half
0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, // 4 tmpvar_1;. tm
0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x28, 0x73, // pvar_1 = half4(s
0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, // _texColor.sample
0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, // (_mtlsmp_s_texCo
0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x29, 0x28, 0x5f, 0x6d, // lor, (float2)(_m
0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, // tl_i.v_texcoord0
0x29, 0x2c, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, // ), level(_mtl_u.
0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, 0x78, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, // u_params.x)));.
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, // _mtl_o.gl_FragC
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x29, 0x28, // olor = ((half4)(
0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x29, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // (float4)tmpvar_1
0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // * _mtl_i.v_colo
0x72, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, // r0));. return _
0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // mtl_o;.}...
};

View File

@ -0,0 +1,19 @@
$input v_texcoord0, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bgfx_shader.sh>
SAMPLER2D(s_texColor, 0);
uniform vec4 u_params;
#define u_textureLod u_params.x
void main()
{
vec4 color = texture2DLod(s_texColor, v_texcoord0, u_textureLod);
gl_FragColor = color * v_color0;
}

View File

@ -0,0 +1,187 @@
static const uint8_t fs_texture_cube_glsl[562] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x03, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x01, 0x00, 0x00, 0x01, 0x00, 0x05, 0x75, 0x5f, 0x6d, 0x74, // Color.......u_mt
0x78, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, // x.......u_params
0x02, 0x01, 0x00, 0x00, 0x01, 0x00, 0xf7, 0x01, 0x00, 0x00, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, // ..........varyin
0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, // g highp vec4 v_c
0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, // olor0;.varying h
0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, // ighp vec2 v_texc
0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x6c, // oord0;.uniform l
0x6f, 0x77, 0x70, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x43, 0x75, 0x62, 0x65, 0x20, // owp samplerCube
0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, // s_texColor;.unif
0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, // orm highp mat4 u
0x5f, 0x6d, 0x74, 0x78, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, // _mtx;.uniform hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, // ghp vec4 u_param
0x73, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, // s;.void main ().
0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x74, // {. highp vec3 t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // mpvar_1;. tmpva
0x72, 0x5f, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, // r_1.z = 1.0;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, // mpvar_1.xy = (((
0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2a, 0x20, 0x32, 0x2e, // v_texcoord0 * 2.
0x30, 0x29, 0x20, 0x2d, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x20, 0x2a, 0x20, 0x76, 0x65, 0x63, 0x32, // 0) - 1.0) * vec2
0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, // (1.0, -1.0));.
0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // highp vec4 tmpva
0x72, 0x5f, 0x32, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, // r_2;. tmpvar_2.
0x77, 0x20, 0x3d, 0x20, 0x30, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // w = 0.0;. tmpva
0x72, 0x5f, 0x32, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // r_2.xyz = tmpvar
0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x6c, 0x6f, 0x77, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, // _1;. lowp vec4
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // tmpvar_3;. tmpv
0x61, 0x72, 0x5f, 0x33, 0x20, 0x3d, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x43, 0x75, // ar_3 = textureCu
0x62, 0x65, 0x4c, 0x6f, 0x64, 0x20, 0x20, 0x20, 0x20, 0x28, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, // beLod (s_texC
0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, // olor, normalize(
0x28, 0x75, 0x5f, 0x6d, 0x74, 0x78, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // (u_mtx * tmpvar_
0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x2c, 0x20, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, // 2).xyz), u_param
0x73, 0x2e, 0x78, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, // s.x);. gl_FragC
0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x28, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, // olor = (tmpvar_3
0x20, 0x2a, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x29, 0x3b, 0x0a, 0x7d, 0x0a, // * v_color0);.}.
0x0a, 0x00, // ..
};
static const uint8_t fs_texture_cube_dx9[505] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x03, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, // FSH........s_tex
0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0x05, 0x75, 0x5f, 0x6d, 0x74, // Color0......u_mt
0x78, 0x14, 0x01, 0x00, 0x00, 0x03, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, // x.......u_params
0x12, 0x01, 0x03, 0x00, 0x01, 0x00, 0xc0, 0x01, 0x00, 0x03, 0xff, 0xff, 0xfe, 0xff, 0x3a, 0x00, // ..............:.
0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0x00, 0x03, 0xff, 0xff, // CTAB............
0x03, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, // ................
0x58, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x02, 0x00, 0x64, 0x00, 0x00, 0x00, // X...........d...
0x00, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ....t...........
0x7c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x02, 0x00, 0x03, 0x00, // |...............
0x01, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x73, 0x5f, 0x74, 0x65, // ............s_te
0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0xab, 0x04, 0x00, 0x0e, 0x00, 0x01, 0x00, 0x01, 0x00, // xColor..........
0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x6d, 0x74, 0x78, 0x00, 0xab, 0xab, // ........u_mtx...
0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x00, 0xab, 0xab, 0xab, 0x01, 0x00, 0x03, 0x00, // u_params........
0x01, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x73, 0x5f, 0x33, // ............ps_3
0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, // _0.Microsoft (R)
0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, // HLSL Shader Com
0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, // piler 10.0.10011
0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x51, 0x00, 0x00, 0x05, 0x04, 0x00, 0x0f, 0xa0, // .16384..Q.......
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x00, 0x00, // ...@.......?....
0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, // ................
0x05, 0x00, 0x00, 0x80, 0x01, 0x00, 0x03, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x98, // ................
0x00, 0x08, 0x0f, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x03, 0x80, 0x01, 0x00, 0xe4, 0x90, // ................
0x04, 0x00, 0x00, 0xa0, 0x04, 0x00, 0x55, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x03, 0x80, // ......U.........
0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0xe6, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0e, 0x80, // ................
0x00, 0x00, 0x55, 0x80, 0x01, 0x00, 0x90, 0xa0, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x07, 0x80, // ..U.............
0x00, 0x00, 0xe4, 0xa0, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0xf9, 0x80, 0x02, 0x00, 0x00, 0x03, // ................
0x00, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0xe4, 0xa0, 0x24, 0x00, 0x00, 0x02, // ............$...
0x01, 0x00, 0x07, 0x80, 0x00, 0x00, 0xe4, 0x80, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, 0x08, 0x80, // ................
0x03, 0x00, 0x00, 0xa0, 0x5f, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0x80, // ...._...........
0x00, 0x08, 0xe4, 0xa0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x08, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0x80, // ................
0x00, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // .........
};
static const uint8_t fs_texture_cube_dx11[736] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x03, 0x00, 0x05, 0x75, 0x5f, 0x6d, 0x74, 0x78, // FSH........u_mtx
0x14, 0x00, 0x00, 0x00, 0x04, 0x00, 0x08, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x12, // .......u_params.
0x00, 0x40, 0x00, 0x01, 0x00, 0x0a, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, // .@....s_texColor
0x30, 0x01, 0x00, 0x00, 0x01, 0x00, 0xa4, 0x02, 0x44, 0x58, 0x42, 0x43, 0x4c, 0x24, 0x47, 0x2e, // 0.......DXBCL$G.
0x14, 0x8a, 0x1d, 0xd0, 0x5e, 0x4b, 0xf7, 0x6a, 0x90, 0x00, 0xd7, 0x38, 0x01, 0x00, 0x00, 0x00, // ....^K.j...8....
0xa4, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, // ........,.......
0xd4, 0x00, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, // ....ISGNl.......
0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ....P...........
0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, // ................
0x0f, 0x0f, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....b...........
0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, // ............SV_P
0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, // OSITION.COLOR.TE
0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x4f, 0x53, 0x47, 0x4e, 0x2c, 0x00, 0x00, 0x00, // XCOORD..OSGN,...
0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........ .......
0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, // ................
0x53, 0x56, 0x5f, 0x54, 0x41, 0x52, 0x47, 0x45, 0x54, 0x00, 0xab, 0xab, 0x53, 0x48, 0x44, 0x52, // SV_TARGET...SHDR
0xc8, 0x01, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x04, // ....@...r...Y...
0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x03, // F. .........Z...
0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x58, 0x30, 0x00, 0x04, 0x00, 0x70, 0x10, 0x00, // .`......X0...p..
0x00, 0x00, 0x00, 0x00, 0x55, 0x55, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, // ....UU..b.......
0x01, 0x00, 0x00, 0x00, 0x62, 0x10, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, // ....b...2.......
0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, // e.... ......h...
0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0f, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ....2...2.......
0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, // F........@.....@
0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, // ...@.........@..
0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x80, 0xbf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x38, 0x00, 0x00, 0x0a, 0x32, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x00, 0x10, 0x00, // 8...2.......F...
0x00, 0x00, 0x00, 0x00, 0x02, 0x40, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x00, 0x00, 0x80, 0xbf, // .....@.....?....
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xe2, 0x00, 0x10, 0x00, // ........8.......
0x00, 0x00, 0x00, 0x00, 0x56, 0x05, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x89, 0x20, 0x00, // ....V......... .
0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0x72, 0x00, 0x10, 0x00, // ........2...r...
0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ....F. .........
0x06, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x96, 0x07, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x00, 0x08, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, // ....r.......F...
0x00, 0x00, 0x00, 0x00, 0x46, 0x82, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, // ....F. .........
0x10, 0x00, 0x00, 0x07, 0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, // ............F...
0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x05, // ....F.......D...
0x82, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........:.......
0x38, 0x00, 0x00, 0x07, 0x72, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0xf6, 0x0f, 0x10, 0x00, // 8...r...........
0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x0c, // ....F.......H...
0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x02, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // ........F.......
0x46, 0x7e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // F~.......`......
0x0a, 0x80, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x07, // .. .........8...
0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, // . ......F.......
0x46, 0x1e, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x00, 0x50, 0x00, // F.......>.....P.
};
static const uint8_t fs_texture_cube_mtl[962] =
{
0x46, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xb3, 0x03, 0x00, 0x00, 0x75, 0x73, // FSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . float4 v_colo
0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x20, 0x76, 0x5f, 0x74, // r0;. float2 v_t
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, // excoord0;.};.str
0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // uct xlatMtlShade
0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, 0x66, // rOutput {. half
0x34, 0x20, 0x67, 0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x3b, 0x0a, // 4 gl_FragColor;.
0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, // };.struct xlatMt
0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, // lShaderUniform {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x74, // . float4x4 u_mt
0x78, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x70, 0x61, // x;. float4 u_pa
0x72, 0x61, 0x6d, 0x73, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x66, 0x72, 0x61, 0x67, 0x6d, 0x65, 0x6e, // rams;.};.fragmen
0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, // t xlatMtlShaderO
0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, // utput xlatMtlMai
0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, // n (xlatMtlShader
0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, // Input _mtl_i [[s
0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, // tage_in]], const
0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, // ant xlatMtlShade
0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, // rUniform& _mtl_u
0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x0a, 0x20, // [[buffer(0)]].
0x20, 0x2c, 0x20, 0x20, 0x20, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x63, 0x75, 0x62, 0x65, // , texturecube
0x3c, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x3e, 0x20, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, // <float> s_texCol
0x6f, 0x72, 0x20, 0x5b, 0x5b, 0x74, 0x65, 0x78, 0x74, 0x75, 0x72, 0x65, 0x28, 0x30, 0x29, 0x5d, // or [[texture(0)]
0x5d, 0x2c, 0x20, 0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x73, // ], sampler _mtls
0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x5b, 0x5b, // mp_s_texColor [[
0x73, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, // sampler(0)]]).{.
0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, // xlatMtlShaderO
0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, // utput _mtl_o;.
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, // float3 tmpvar_1;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x7a, 0x20, 0x3d, 0x20, // . tmpvar_1.z =
0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, // 1.0;. tmpvar_1.
0x78, 0x79, 0x20, 0x3d, 0x20, 0x28, 0x28, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x76, // xy = (((_mtl_i.v
0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x2a, 0x20, 0x32, 0x2e, 0x30, // _texcoord0 * 2.0
0x29, 0x20, 0x2d, 0x20, 0x31, 0x2e, 0x30, 0x29, 0x20, 0x2a, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, // ) - 1.0) * float
0x32, 0x28, 0x31, 0x2e, 0x30, 0x2c, 0x20, 0x2d, 0x31, 0x2e, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, // 2(1.0, -1.0));.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // float4 tmpvar_2
0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, 0x2e, 0x77, 0x20, 0x3d, // ;. tmpvar_2.w =
0x20, 0x30, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x32, // 0.0;. tmpvar_2
0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, // .xyz = tmpvar_1;
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, // . float3 tmpvar
0x5f, 0x33, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x20, 0x3d, // _3;. tmpvar_3 =
0x20, 0x6e, 0x6f, 0x72, 0x6d, 0x61, 0x6c, 0x69, 0x7a, 0x65, 0x28, 0x28, 0x5f, 0x6d, 0x74, 0x6c, // normalize((_mtl
0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, 0x74, 0x78, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, // _u.u_mtx * tmpva
0x72, 0x5f, 0x32, 0x29, 0x2e, 0x78, 0x79, 0x7a, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x68, 0x61, 0x6c, // r_2).xyz);. hal
0x66, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x3b, 0x0a, 0x20, 0x20, 0x74, // f4 tmpvar_4;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x20, 0x3d, 0x20, 0x68, 0x61, 0x6c, 0x66, 0x34, 0x28, // mpvar_4 = half4(
0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x2e, 0x73, 0x61, 0x6d, 0x70, 0x6c, // s_texColor.sampl
0x65, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x73, 0x6d, 0x70, 0x5f, 0x73, 0x5f, 0x74, 0x65, 0x78, 0x43, // e(_mtlsmp_s_texC
0x6f, 0x6c, 0x6f, 0x72, 0x2c, 0x20, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x29, 0x28, 0x74, // olor, (float3)(t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x33, 0x29, 0x2c, 0x20, 0x6c, 0x65, 0x76, 0x65, 0x6c, 0x28, // mpvar_3), level(
0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x73, 0x2e, // _mtl_u.u_params.
0x78, 0x29, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, // x)));. _mtl_o.g
0x6c, 0x5f, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x20, 0x3d, 0x20, 0x28, 0x28, // l_FragColor = ((
0x68, 0x61, 0x6c, 0x66, 0x34, 0x29, 0x28, 0x28, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x29, 0x74, // half4)((float4)t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x34, 0x20, 0x2a, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, // mpvar_4 * _mtl_i
0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x29, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x72, // .v_color0));. r
0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, // eturn _mtl_o;.}.
0x0a, 0x00, // ..
};

View File

@ -0,0 +1,21 @@
$input v_texcoord0, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bgfx_shader.sh>
SAMPLERCUBE(s_texColor, 0);
uniform mat4 u_mtx;
uniform vec4 u_params;
#define u_textureLod u_params.x
void main()
{
vec3 dir = vec3( (v_texcoord0*2.0 - 1.0) * vec2(1.0, -1.0), 1.0);
dir = normalize(mul(u_mtx, vec4(dir, 0.0) ).xyz);
gl_FragColor = textureCubeLod(s_texColor, dir, u_textureLod) * v_color0;
}

6
3rdparty/bgfx/tools/texturev/makefile vendored Normal file
View File

@ -0,0 +1,6 @@
#
# Copyright 2011-2015 Branimir Karadzic. All rights reserved.
# License: http://www.opensource.org/licenses/BSD-2-Clause
#
include ../../../bgfx/scripts/shader-embeded.mk

View File

@ -0,0 +1,718 @@
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include "common.h"
#include <bgfx/bgfx.h>
#include <bx/os.h>
#include <bx/string.h>
#include <bx/uint32_t.h>
#include <entry/entry.h>
#include <entry/input.h>
#include <entry/cmd.h>
#include <imgui/imgui.h>
#include <bgfx_utils.h>
#include <dirent.h>
#include "vs_texture.bin.h"
#include "fs_texture.bin.h"
#include "vs_texture_cube.bin.h"
#include "fs_texture_cube.bin.h"
#include <bx/crtimpl.h>
#include <tinystl/allocator.h>
#include <tinystl/vector.h>
#include <string>
namespace stl = tinystl;
#include "image.h"
struct Binding
{
enum Enum
{
App,
View,
Count
};
};
static const InputBinding s_bindingApp[] =
{
{ entry::Key::Esc, entry::Modifier::None, 1, NULL, "exit" },
{ entry::Key::KeyF, entry::Modifier::None, 1, NULL, "graphics fullscreen" },
INPUT_BINDING_END
};
static const InputBinding s_bindingView[] =
{
{ entry::Key::Comma, entry::Modifier::None, 1, NULL, "view mip prev" },
{ entry::Key::Period, entry::Modifier::None, 1, NULL, "view mip next" },
{ entry::Key::Comma, entry::Modifier::LeftShift, 1, NULL, "view mip" },
{ entry::Key::Comma, entry::Modifier::RightShift, 1, NULL, "view mip" },
{ entry::Key::Slash, entry::Modifier::None, 1, NULL, "view filter" },
{ entry::Key::Key0, entry::Modifier::None, 1, NULL, "view zoom 1.0" },
{ entry::Key::Plus, entry::Modifier::None, 1, NULL, "view zoom +0.1" },
{ entry::Key::Minus, entry::Modifier::None, 1, NULL, "view zoom -0.1" },
{ entry::Key::Up, entry::Modifier::None, 1, NULL, "view file-up" },
{ entry::Key::Down, entry::Modifier::None, 1, NULL, "view file-down" },
{ entry::Key::PageUp, entry::Modifier::None, 1, NULL, "view file-pgup" },
{ entry::Key::PageDown, entry::Modifier::None, 1, NULL, "view file-pgdown" },
{ entry::Key::KeyH, entry::Modifier::None, 1, NULL, "view help" },
INPUT_BINDING_END
};
static const char* s_bindingName[] =
{
"App",
"View",
};
BX_STATIC_ASSERT(Binding::Count == BX_COUNTOF(s_bindingName) );
static const InputBinding* s_binding[] =
{
s_bindingApp,
s_bindingView,
};
BX_STATIC_ASSERT(Binding::Count == BX_COUNTOF(s_binding) );
struct View
{
View()
: m_fileIndex(0)
, m_scaleFn(0)
, m_mip(0)
, m_zoom(1.0f)
, m_filter(true)
, m_help(false)
{
}
~View()
{
}
int32_t cmd(int32_t _argc, char const* const* _argv)
{
if (_argc >= 2)
{
if (0 == strcmp(_argv[1], "mip") )
{
if (_argc >= 3)
{
uint32_t mip = m_mip;
if (0 == strcmp(_argv[2], "next") )
{
++mip;
}
else if (0 == strcmp(_argv[2], "prev") )
{
--mip;
}
else if (0 == strcmp(_argv[2], "last") )
{
mip = INT32_MAX;
}
else
{
mip = atoi(_argv[2]);
}
m_mip = bx::uint32_iclamp(mip, 0, m_info.numMips-1);
}
else
{
m_mip = 0;
}
}
else if (0 == strcmp(_argv[1], "zoom") )
{
if (_argc >= 3)
{
float zoom = (float)atof(_argv[2]);
if (_argv[2][0] == '+'
|| _argv[2][0] == '-')
{
m_zoom += zoom;
}
else
{
m_zoom = zoom;
}
m_zoom = bx::fclamp(m_zoom, 0.001f, 10.0f);
}
else
{
m_zoom = 1.0f;
}
}
else if (0 == strcmp(_argv[1], "filter") )
{
if (_argc >= 3)
{
m_filter = bx::toBool(_argv[2]);
}
else
{
m_filter ^= true;
}
}
else if (0 == strcmp(_argv[1], "file-up") )
{
m_fileIndex = bx::uint32_satsub(m_fileIndex, 1);
}
else if (0 == strcmp(_argv[1], "file-down") )
{
uint32_t numFiles = bx::uint32_satsub(uint32_t(m_fileList.size() ), 1);
++m_fileIndex;
m_fileIndex = bx::uint32_min(m_fileIndex, numFiles);
}
else if (0 == strcmp(_argv[1], "help") )
{
m_help ^= true;
}
}
return 0;
}
void updateFileList(const char* _path, const char* _fileName = "")
{
std::string path = _path;
DIR* dir = opendir(_path);
if (NULL == dir)
{
path = ".";
}
dir = opendir(path.c_str() );
if (NULL != dir)
{
for (dirent* item = readdir(dir); NULL != item; item = readdir(dir) )
{
if (0 == (item->d_type & DT_DIR) )
{
const char* ext = strrchr(item->d_name, '.');
if (NULL != ext)
{
if (0 == bx::stricmp(ext, ".dds")
|| 0 == bx::stricmp(ext, ".jpg")
|| 0 == bx::stricmp(ext, ".jpeg")
|| 0 == bx::stricmp(ext, ".hdr")
|| 0 == bx::stricmp(ext, ".ktx")
|| 0 == bx::stricmp(ext, ".png")
|| 0 == bx::stricmp(ext, ".pvr")
|| 0 == bx::stricmp(ext, ".tga")
)
{
if (0 == strcmp(_fileName, item->d_name) )
{
m_fileIndex = uint32_t(m_fileList.size() );
}
std::string name = path;
char ch = name.back();
name += '/' == ch || '\\' == ch ? "" : "/";
name += item->d_name;
m_fileList.push_back(name);
}
}
}
}
closedir(dir);
}
}
typedef stl::vector<std::string> FileList;
FileList m_fileList;
bgfx::TextureInfo m_info;
uint32_t m_fileIndex;
uint32_t m_scaleFn;
uint32_t m_mip;
float m_zoom;
bool m_filter;
bool m_help;
};
int cmdView(CmdContext* /*_context*/, void* _userData, int _argc, char const* const* _argv)
{
View* view = static_cast<View*>(_userData);
return view->cmd(_argc, _argv);
}
struct PosUvColorVertex
{
float m_x;
float m_y;
float m_u;
float m_v;
uint32_t m_abgr;
static void init()
{
ms_decl
.begin()
.add(bgfx::Attrib::Position, 2, bgfx::AttribType::Float)
.add(bgfx::Attrib::TexCoord0, 2, bgfx::AttribType::Float)
.add(bgfx::Attrib::Color0, 4, bgfx::AttribType::Uint8, true)
.end();
}
static bgfx::VertexDecl ms_decl;
};
bgfx::VertexDecl PosUvColorVertex::ms_decl;
bool screenQuad(int32_t _x, int32_t _y, int32_t _width, uint32_t _height, bool _originBottomLeft = false)
{
if (bgfx::checkAvailTransientVertexBuffer(6, PosUvColorVertex::ms_decl) )
{
bgfx::TransientVertexBuffer vb;
bgfx::allocTransientVertexBuffer(&vb, 6, PosUvColorVertex::ms_decl);
PosUvColorVertex* vertex = (PosUvColorVertex*)vb.data;
const float widthf = float(_width);
const float heightf = float(_height);
const float minx = float(_x);
const float miny = float(_y);
const float maxx = minx+widthf;
const float maxy = miny+heightf;
float m_halfTexel = 0.0f;
const float texelHalfW = m_halfTexel/widthf;
const float texelHalfH = m_halfTexel/heightf;
const float minu = texelHalfW;
const float maxu = 1.0f - texelHalfW;
const float minv = _originBottomLeft ? texelHalfH+1.0f : texelHalfH ;
const float maxv = _originBottomLeft ? texelHalfH : texelHalfH+1.0f;
vertex[0].m_x = minx;
vertex[0].m_y = miny;
vertex[0].m_u = minu;
vertex[0].m_v = minv;
vertex[1].m_x = maxx;
vertex[1].m_y = miny;
vertex[1].m_u = maxu;
vertex[1].m_v = minv;
vertex[2].m_x = maxx;
vertex[2].m_y = maxy;
vertex[2].m_u = maxu;
vertex[2].m_v = maxv;
vertex[3].m_x = maxx;
vertex[3].m_y = maxy;
vertex[3].m_u = maxu;
vertex[3].m_v = maxv;
vertex[4].m_x = minx;
vertex[4].m_y = maxy;
vertex[4].m_u = minu;
vertex[4].m_v = maxv;
vertex[5].m_x = minx;
vertex[5].m_y = miny;
vertex[5].m_u = minu;
vertex[5].m_v = minv;
vertex[0].m_abgr = UINT32_MAX;
vertex[1].m_abgr = UINT32_MAX;
vertex[2].m_abgr = UINT32_MAX;
vertex[3].m_abgr = UINT32_MAX;
vertex[4].m_abgr = UINT32_MAX;
vertex[5].m_abgr = UINT32_MAX;
bgfx::setVertexBuffer(&vb);
return true;
}
return false;
}
struct Interpolator
{
float from;
float to;
float duration;
int64_t offset;
Interpolator(float _value)
{
reset(_value);
}
void reset(float _value)
{
from = _value;
to = _value;
duration = 0.0;
offset = bx::getHPCounter();
}
void set(float _value, float _duration)
{
if (_value != to)
{
from = getValue();
to = _value;
duration = _duration;
offset = bx::getHPCounter();
}
}
float getValue()
{
if (duration > 0.0)
{
const double freq = double(bx::getHPFrequency() );
int64_t now = bx::getHPCounter();
float time = (float)(double(now - offset) / freq);
float lerp = bx::fclamp(time, 0.0, duration) / duration;
return bx::flerp(from, to, lerp);
}
return to;
}
};
void help(const char* _error = NULL)
{
if (NULL != _error)
{
fprintf(stderr, "Error:\n%s\n\n", _error);
}
fprintf(stderr
, "texturev, bgfx texture viewer tool\n"
"Copyright 2011-2016 Branimir Karadzic. All rights reserved.\n"
"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n\n"
);
fprintf(stderr
, "Usage: texturev <file path>\n"
"\n"
"For additional information, see https://github.com/bkaradzic/bgfx\n"
);
}
int _main_(int _argc, char** _argv)
{
uint32_t width = 1280;
uint32_t height = 720;
uint32_t debug = BGFX_DEBUG_TEXT;
uint32_t reset = BGFX_RESET_VSYNC;
inputAddBindings(s_bindingName[Binding::App], s_binding[Binding::App]);
inputAddBindings(s_bindingName[Binding::View], s_binding[Binding::View]);
View view;
cmdAdd("view", cmdView, &view);
bgfx::init();
bgfx::reset(width, height, reset);
// Set view 0 clear state.
bgfx::setViewClear(0
, BGFX_CLEAR_COLOR|BGFX_CLEAR_DEPTH
, 0x101010ff
, 1.0f
, 0
);
imguiCreate();
PosUvColorVertex::init();
const bgfx::Memory* vs_texture;
const bgfx::Memory* fs_texture;
const bgfx::Memory* vs_texture_cube;
const bgfx::Memory* fs_texture_cube;
switch (bgfx::getRendererType())
{
case bgfx::RendererType::Direct3D9:
vs_texture = bgfx::makeRef(vs_texture_dx9, sizeof(vs_texture_dx9) );
fs_texture = bgfx::makeRef(fs_texture_dx9, sizeof(fs_texture_dx9) );
vs_texture_cube = bgfx::makeRef(vs_texture_cube_dx9, sizeof(vs_texture_cube_dx9) );
fs_texture_cube = bgfx::makeRef(fs_texture_cube_dx9, sizeof(fs_texture_cube_dx9) );
break;
case bgfx::RendererType::Direct3D11:
case bgfx::RendererType::Direct3D12:
vs_texture = bgfx::makeRef(vs_texture_dx11, sizeof(vs_texture_dx11) );
fs_texture = bgfx::makeRef(fs_texture_dx11, sizeof(fs_texture_dx11) );
vs_texture_cube = bgfx::makeRef(vs_texture_cube_dx11, sizeof(vs_texture_cube_dx11) );
fs_texture_cube = bgfx::makeRef(fs_texture_cube_dx11, sizeof(fs_texture_cube_dx11) );
break;
default:
vs_texture = bgfx::makeRef(vs_texture_glsl, sizeof(vs_texture_glsl) );
fs_texture = bgfx::makeRef(fs_texture_glsl, sizeof(fs_texture_glsl) );
vs_texture_cube = bgfx::makeRef(vs_texture_cube_glsl, sizeof(vs_texture_cube_glsl) );
fs_texture_cube = bgfx::makeRef(fs_texture_cube_glsl, sizeof(fs_texture_cube_glsl) );
break;
}
bgfx::ProgramHandle textureProgram = bgfx::createProgram(
bgfx::createShader(vs_texture)
, bgfx::createShader(fs_texture)
, true
);
bgfx::ProgramHandle textureCubeProgram = bgfx::createProgram(
bgfx::createShader(vs_texture_cube)
, bgfx::createShader(fs_texture_cube)
, true
);
bgfx::UniformHandle s_texColor = bgfx::createUniform("s_texColor", bgfx::UniformType::Int1);
bgfx::UniformHandle u_mtx = bgfx::createUniform("u_mtx", bgfx::UniformType::Mat4);
bgfx::UniformHandle u_params = bgfx::createUniform("u_params", bgfx::UniformType::Vec4);
float speed = 0.37f;
float time = 0.0f;
Interpolator mip(0.0);
Interpolator zoom(1.0);
Interpolator scale(1.0);
const char* filePath = _argc < 2 ? "" : _argv[1];
bool directory = false;
bx::FileInfo fi;
bx::stat(filePath, fi);
directory = bx::FileInfo::Directory == fi.m_type;
std::string path = filePath;
if (!directory)
{
const char* fileName = directory ? filePath : bx::baseName(filePath);
path.assign(filePath, fileName);
view.updateFileList(path.c_str(), fileName);
}
else
{
view.updateFileList(path.c_str() );
}
int exitcode = EXIT_SUCCESS;
bgfx::TextureHandle texture = BGFX_INVALID_HANDLE;
if (view.m_fileList.empty() )
{
exitcode = EXIT_FAILURE;
if (2 > _argc)
{
help("File path is not specified.");
}
else
{
fprintf(stderr, "Unable to load '%s' texture.\n", filePath);
}
}
else
{
uint32_t fileIndex = 0;
entry::MouseState mouseState;
while (!entry::processEvents(width, height, debug, reset, &mouseState) )
{
imguiBeginFrame(mouseState.m_mx
, mouseState.m_my
, (mouseState.m_buttons[entry::MouseButton::Left ] ? IMGUI_MBUT_LEFT : 0)
| (mouseState.m_buttons[entry::MouseButton::Right ] ? IMGUI_MBUT_RIGHT : 0)
| (mouseState.m_buttons[entry::MouseButton::Middle] ? IMGUI_MBUT_MIDDLE : 0)
, mouseState.m_mz
, width
, height
);
static bool help = false;
if (help == false
&& help != view.m_help)
{
ImGui::OpenPopup("Help");
}
if (ImGui::BeginPopupModal("Help", NULL, ImGuiWindowFlags_AlwaysAutoResize) )
{
ImGui::SetWindowFontScale(1.2f);
ImGui::Text(
"texturev, bgfx texture viewer tool\n"
"Copyright 2011-2016 Branimir Karadzic. All rights reserved.\n"
"License: https://github.com/bkaradzic/bgfx#license-bsd-2-clause\n"
);
ImGui::Separator();
ImGui::NextLine();
ImGui::Text("Key bindings:\n\n");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "ESC"); ImGui::SameLine(64); ImGui::Text("Exit.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "h"); ImGui::SameLine(64); ImGui::Text("Toggle help screen.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "f"); ImGui::SameLine(64); ImGui::Text("Toggle full-screen.");
ImGui::NextLine();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "-"); ImGui::SameLine(64); ImGui::Text("Zoom out.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "="); ImGui::SameLine(64); ImGui::Text("Zoom in.");
ImGui::NextLine();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), ","); ImGui::SameLine(64); ImGui::Text("MIP level up.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "."); ImGui::SameLine(64); ImGui::Text("MIP level down.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "/"); ImGui::SameLine(64); ImGui::Text("Toggle linear/point texture sampling.");
ImGui::NextLine();
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "up"); ImGui::SameLine(64); ImGui::Text("Previous texture.");
ImGui::TextColored(ImVec4(1.0f, 1.0f, 0.0f, 1.0f), "down"); ImGui::SameLine(64); ImGui::Text("Next texture.");
ImGui::NextLine();
ImGui::Dummy(ImVec2(0.0f, 0.0f) );
ImGui::SameLine(ImGui::GetWindowWidth() - 136.0f);
if (ImGui::Button("Close", ImVec2(128.0f, 0.0f) )
|| !view.m_help)
{
view.m_help = false;
ImGui::CloseCurrentPopup();
}
ImGui::EndPopup();
}
help = view.m_help;
// bool b;
// ImGui::ShowTestWindow(&b);
imguiEndFrame();
if (!bgfx::isValid(texture)
|| view.m_fileIndex != fileIndex)
{
if (bgfx::isValid(texture) )
{
bgfx::destroyTexture(texture);
}
fileIndex = view.m_fileIndex;
filePath = view.m_fileList[view.m_fileIndex].c_str();
texture = loadTexture(filePath
, 0
| BGFX_TEXTURE_U_CLAMP
| BGFX_TEXTURE_V_CLAMP
| BGFX_TEXTURE_W_CLAMP
, 0
, &view.m_info
);
std::string title;
bx::stringPrintf(title, "%s (%d x %d%s, %s)"
, filePath
, view.m_info.width
, view.m_info.height
, view.m_info.cubeMap ? " CubeMap" : ""
, bgfx::getName(view.m_info.format)
);
entry::WindowHandle handle = { 0 };
entry::setWindowTitle(handle, title.c_str() );
}
int64_t now = bx::getHPCounter();
static int64_t last = now;
const int64_t frameTime = now - last;
last = now;
const double freq = double(bx::getHPFrequency() );
time += (float)(frameTime*speed/freq);
float ortho[16];
bx::mtxOrtho(ortho, 0.0f, (float)width, (float)height, 0.0f, 0.0f, 1000.0f);
bgfx::setViewTransform(0, NULL, ortho);
bgfx::setViewRect(0, 0, 0, width, height);
bgfx::touch(0);
bgfx::dbgTextClear();
scale.set(
bx::fmin( float(width) / float(view.m_info.width)
, float(height) / float(view.m_info.height)
)
, 0.1f
);
zoom.set(view.m_zoom, 0.25);
float ss = scale.getValue() * zoom.getValue();
screenQuad( int(width - view.m_info.width * ss)/2
, int(height - view.m_info.height * ss)/2
, int(view.m_info.width * ss)
, int(view.m_info.height * ss)
);
float mtx[16];
bx::mtxRotateXY(mtx, 0.0f, time);
bgfx::setUniform(u_mtx, mtx);
mip.set( float(view.m_mip), 0.5f);
float params[4] = { mip.getValue(), 0.0f, 0.0f, 0.0f };
bgfx::setUniform(u_params, params);
bgfx::setTexture(0
, s_texColor
, texture
, view.m_filter
? BGFX_TEXTURE_NONE
: 0
| BGFX_TEXTURE_MIN_POINT
| BGFX_TEXTURE_MIP_POINT
| BGFX_TEXTURE_MAG_POINT
);
bgfx::setState(0
| BGFX_STATE_RGB_WRITE
| BGFX_STATE_ALPHA_WRITE
);
bgfx::submit(0, view.m_info.cubeMap ? textureCubeProgram : textureProgram);
bgfx::frame();
}
}
if (bgfx::isValid(texture) )
{
bgfx::destroyTexture(texture);
}
bgfx::destroyUniform(s_texColor);
bgfx::destroyUniform(u_mtx);
bgfx::destroyUniform(u_params);
bgfx::destroyProgram(textureProgram);
bgfx::destroyProgram(textureCubeProgram);
imguiDestroy();
bgfx::shutdown();
return exitcode;
}

View File

@ -0,0 +1,8 @@
vec4 v_color0 : COLOR0 = vec4(1.0, 0.0, 0.0, 1.0);
vec3 v_normal : NORMAL = vec3(0.0, 0.0, 1.0);
vec2 v_texcoord0 : TEXCOORD0 = vec2(0.0, 0.0);
vec3 a_position : POSITION;
vec4 a_normal : NORMAL;
vec4 a_color0 : COLOR0;
vec2 a_texcoord0 : TEXCOORD0;

View File

@ -0,0 +1,144 @@
static const uint8_t vs_texture_glsl[419] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, 0x83, 0x01, 0x00, 0x00, 0x61, // wProj..........a
0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // ttribute highp v
0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x61, 0x74, // ec4 a_color0;.at
0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // tribute highp ve
0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x61, // c3 a_position;.a
0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // ttribute highp v
0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, // ec2 a_texcoord0;
0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, // .varying highp v
0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x76, 0x61, // ec4 v_color0;.va
0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, // rying highp vec2
0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x75, 0x6e, // v_texcoord0;.un
0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x6d, 0x61, 0x74, 0x34, // iform highp mat4
0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, // u_viewProj;.voi
0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, // d main ().{. hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, // ghp vec4 tmpvar_
0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x7a, 0x77, // 1;. tmpvar_1.zw
0x20, 0x3d, 0x20, 0x76, 0x65, 0x63, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, // = vec2(0.0, 1.0
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, // );. tmpvar_1.xy
0x20, 0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, // = a_position.xy
0x3b, 0x0a, 0x20, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, // ;. gl_Position
0x3d, 0x20, 0x28, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, // = (u_viewProj *
0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x74, // tmpvar_1);. v_t
0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, // excoord0 = a_tex
0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // coord0;. v_colo
0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x7d, // r0 = a_color0;.}
0x0a, 0x0a, 0x00, // ...
};
static const uint8_t vs_texture_dx9[330] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, 0x2c, 0x01, 0x00, 0x03, 0xfe, // wProj......,....
0xff, 0xfe, 0xff, 0x23, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, // ...#.CTAB....S..
0x00, 0x00, 0x03, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x00, 0x91, 0x00, // ................
0x00, 0x4c, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, // .L...0..........
0x00, 0x3c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, // .<.......u_viewP
0x72, 0x6f, 0x6a, 0x00, 0xab, 0x03, 0x00, 0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, // roj.............
0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, 0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, // .....vs_3_0.Micr
0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, 0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, // osoft (R) HLSL S
0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, 0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, // hader Compiler 1
0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, 0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, // 0.0.10011.16384.
0xab, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, // ................
0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, // ................
0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, // ................
0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, 0x00, 0x80, 0x01, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, // ................
0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x03, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, // ................
0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, // .......U........
0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, // ................
0x03, 0x00, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, // ................
0x02, 0x01, 0x00, 0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x03, // ................
0xe0, 0x02, 0x00, 0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // ..........
};
static const uint8_t vs_texture_dx11[575] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0a, 0x75, 0x5f, 0x76, 0x69, 0x65, // VSH........u_vie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, 0x18, 0x02, 0x44, 0x58, 0x42, // wProj........DXB
0x43, 0x02, 0x1b, 0xea, 0x24, 0x10, 0xd8, 0x6f, 0x23, 0xf5, 0xf6, 0x01, 0x38, 0x5b, 0x08, 0x13, // C...$..o#...8[..
0x4d, 0x01, 0x00, 0x00, 0x00, 0x18, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, // M............,..
0x00, 0x9c, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x49, 0x53, 0x47, 0x4e, 0x68, 0x00, 0x00, // .........ISGNh..
0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........P......
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x0f, 0x00, // ................
0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // .V..............
0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x03, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ........._......
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x03, 0x00, // ................
0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, // .COLOR.POSITION.
0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, 0x47, 0x4e, 0x6c, 0x00, 0x00, // TEXCOORD.OSGNl..
0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........P......
0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, // ................
0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // .........b......
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x03, 0x0c, 0x00, // ................
0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, 0x4e, 0x00, 0x43, 0x4f, 0x4c, // .SV_POSITION.COL
0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0xab, 0x53, 0x48, 0x44, // OR.TEXCOORD..SHD
0x52, 0x00, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x40, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, // R....@...@...Y..
0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, // .F. ........._..
0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, // ........._...2..
0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, // ....._...2......
0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .g.... .........
0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, // .e.... ......e..
0x03, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x02, 0x01, 0x00, 0x00, // .2 ......h......
0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x56, 0x15, 0x10, // .8...........V..
0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, // .....F. ........
0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, // .2...........F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, // ................
0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, // .F............ .
0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, // .....F.......F.
0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, // .........6.... .
0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, // .....F.......6..
0x05, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, // .2 ......F......
0x00, 0x3e, 0x00, 0x00, 0x01, 0x00, 0x03, 0x05, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // .>...........@.
};
static const uint8_t vs_texture_mtl[757] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xe6, 0x02, 0x00, 0x00, 0x75, 0x73, // VSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . float4 a_colo
0x72, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, // r0 [[attribute(0
0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, // )]];. float3 a_
0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, // position [[attri
0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // bute(1)]];. flo
0x61, 0x74, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, // at2 a_texcoord0
0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, // [[attribute(2)]]
0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // ;.};.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, // MtlShaderOutput
0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // {. float4 gl_Po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // sition [[positio
0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, // n]];. float4 v_
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, // color0;. float2
0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, // v_texcoord0;.};
0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, // .struct xlatMtlS
0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, // haderUniform {.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, // float4x4 u_view
0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, 0x72, 0x74, 0x65, 0x78, 0x20, // Proj;.};.vertex
0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, // xlatMtlShaderOut
0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x4d, 0x61, 0x69, 0x6e, 0x20, // put xlatMtlMain
0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, // (xlatMtlShaderIn
0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, 0x5b, 0x5b, 0x73, 0x74, 0x61, // put _mtl_i [[sta
0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, // ge_in]], constan
0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x55, // t xlatMtlShaderU
0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x20, 0x5b, // niform& _mtl_u [
0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, 0x5d, 0x29, 0x0a, 0x7b, 0x0a, // [buffer(0)]]).{.
0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, // xlatMtlShaderO
0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x20, 0x20, // utput _mtl_o;.
0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, // float4 tmpvar_1;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x7a, 0x77, 0x20, 0x3d, // . tmpvar_1.zw =
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, 0x28, 0x30, 0x2e, 0x30, 0x2c, 0x20, 0x31, 0x2e, 0x30, // float2(0.0, 1.0
0x29, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, // );. tmpvar_1.xy
0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, // = _mtl_i.a_posi
0x74, 0x69, 0x6f, 0x6e, 0x2e, 0x78, 0x79, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // tion.xy;. _mtl_
0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, // o.gl_Position =
0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x76, 0x69, 0x65, 0x77, 0x50, 0x72, // (_mtl_u.u_viewPr
0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, // oj * tmpvar_1);.
0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, // _mtl_o.v_texco
0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, // ord0 = _mtl_i.a_
0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, // texcoord0;. _mt
0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x5f, // l_o.v_color0 = _
0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, // mtl_i.a_color0;.
0x20, 0x20, 0x72, 0x65, 0x74, 0x75, 0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, // return _mtl_o;
0x0a, 0x7d, 0x0a, 0x0a, 0x00, // .}...
};

View File

@ -0,0 +1,16 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bgfx_shader.sh>
void main()
{
gl_Position = mul(u_viewProj, vec4(a_position.xy, 0.0, 1.0) );
v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}

View File

@ -0,0 +1,148 @@
static const uint8_t vs_texture_cube_glsl[420] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x01, 0x00, // elViewProj......
0x7f, 0x01, 0x00, 0x00, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // ....attribute hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ghp vec4 a_color
0x30, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, 0x67, // 0;.attribute hig
0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x33, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, // hp vec3 a_positi
0x6f, 0x6e, 0x3b, 0x0a, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x20, 0x68, 0x69, // on;.attribute hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, // ghp vec2 a_texco
0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, // ord0;.varying hi
0x67, 0x68, 0x70, 0x20, 0x76, 0x65, 0x63, 0x34, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, // ghp vec4 v_color
0x30, 0x3b, 0x0a, 0x76, 0x61, 0x72, 0x79, 0x69, 0x6e, 0x67, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // 0;.varying highp
0x20, 0x76, 0x65, 0x63, 0x32, 0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, // vec2 v_texcoord
0x30, 0x3b, 0x0a, 0x75, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, // 0;.uniform highp
0x20, 0x6d, 0x61, 0x74, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, // mat4 u_modelVie
0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x76, 0x6f, 0x69, 0x64, 0x20, 0x6d, 0x61, 0x69, 0x6e, // wProj;.void main
0x20, 0x28, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x68, 0x69, 0x67, 0x68, 0x70, 0x20, 0x76, 0x65, // ().{. highp ve
0x63, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, // c4 tmpvar_1;. t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, // mpvar_1.w = 1.0;
0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, // . tmpvar_1.xyz
0x3d, 0x20, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, // = a_position;.
0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x75, // gl_Position = (u
0x5f, 0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, // _modelViewProj *
0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, // tmpvar_1);. v_
0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x74, 0x65, // texcoord0 = a_te
0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x76, 0x5f, 0x63, 0x6f, 0x6c, // xcoord0;. v_col
0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, // or0 = a_color0;.
0x7d, 0x0a, 0x0a, 0x00, // }...
};
static const uint8_t vs_texture_cube_dx9[359] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x01, 0x00, 0x00, 0x04, 0x00, // elViewProj......
0x44, 0x01, 0x00, 0x03, 0xfe, 0xff, 0xfe, 0xff, 0x24, 0x00, 0x43, 0x54, 0x41, 0x42, 0x1c, 0x00, // D.......$.CTAB..
0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x00, 0x03, 0xfe, 0xff, 0x01, 0x00, 0x00, 0x00, 0x1c, 0x00, // ..W.............
0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x02, 0x00, // ......P...0.....
0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x75, 0x5f, // ......@.......u_
0x6d, 0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x00, 0x03, 0x00, // modelViewProj...
0x03, 0x00, 0x04, 0x00, 0x04, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x76, 0x73, // ..............vs
0x5f, 0x33, 0x5f, 0x30, 0x00, 0x4d, 0x69, 0x63, 0x72, 0x6f, 0x73, 0x6f, 0x66, 0x74, 0x20, 0x28, // _3_0.Microsoft (
0x52, 0x29, 0x20, 0x48, 0x4c, 0x53, 0x4c, 0x20, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x20, 0x43, // R) HLSL Shader C
0x6f, 0x6d, 0x70, 0x69, 0x6c, 0x65, 0x72, 0x20, 0x31, 0x30, 0x2e, 0x30, 0x2e, 0x31, 0x30, 0x30, // ompiler 10.0.100
0x31, 0x31, 0x2e, 0x31, 0x36, 0x33, 0x38, 0x34, 0x00, 0xab, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, // 11.16384........
0x00, 0x80, 0x00, 0x00, 0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x01, 0x00, // ................
0x0f, 0x90, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, 0x0f, 0x90, 0x1f, 0x00, // ................
0x00, 0x02, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x0a, 0x00, // ................
0x00, 0x80, 0x01, 0x00, 0x0f, 0xe0, 0x1f, 0x00, 0x00, 0x02, 0x05, 0x00, 0x00, 0x80, 0x02, 0x00, // ................
0x03, 0xe0, 0x05, 0x00, 0x00, 0x03, 0x00, 0x00, 0x0f, 0x80, 0x01, 0x00, 0xe4, 0xa0, 0x01, 0x00, // ................
0x55, 0x90, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x00, 0x00, 0xe4, 0xa0, 0x01, 0x00, // U...............
0x00, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x04, 0x00, 0x00, 0x04, 0x00, 0x00, 0x0f, 0x80, 0x02, 0x00, // ................
0xe4, 0xa0, 0x01, 0x00, 0xaa, 0x90, 0x00, 0x00, 0xe4, 0x80, 0x02, 0x00, 0x00, 0x03, 0x00, 0x00, // ................
0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x80, 0x03, 0x00, 0xe4, 0xa0, 0x01, 0x00, 0x00, 0x02, 0x01, 0x00, // ................
0x0f, 0xe0, 0x00, 0x00, 0xe4, 0x90, 0x01, 0x00, 0x00, 0x02, 0x02, 0x00, 0x03, 0xe0, 0x02, 0x00, // ................
0xe4, 0x90, 0xff, 0xff, 0x00, 0x00, 0x00, // .......
};
static const uint8_t vs_texture_cube_dx11[620] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x01, 0x00, 0x0f, 0x75, 0x5f, 0x6d, 0x6f, 0x64, // VSH........u_mod
0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x04, 0x00, 0x00, 0x00, 0x04, 0x00, // elViewProj......
0x40, 0x02, 0x44, 0x58, 0x42, 0x43, 0x25, 0x0b, 0xbc, 0xf2, 0xf1, 0x2f, 0x13, 0x1a, 0x84, 0x83, // @.DXBC%..../....
0x08, 0xf9, 0x08, 0xa1, 0x2c, 0x84, 0x01, 0x00, 0x00, 0x00, 0x40, 0x02, 0x00, 0x00, 0x03, 0x00, // ....,.....@.....
0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x10, 0x01, 0x00, 0x00, 0x49, 0x53, // ..,...........IS
0x47, 0x4e, 0x68, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, // GNh...........P.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x0f, 0x0f, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ......V.........
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x07, 0x00, 0x00, 0x5f, 0x00, // .............._.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, // ................
0x00, 0x00, 0x03, 0x03, 0x00, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x50, 0x4f, 0x53, 0x49, // ......COLOR.POSI
0x54, 0x49, 0x4f, 0x4e, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, 0x00, 0x4f, 0x53, // TION.TEXCOORD.OS
0x47, 0x4e, 0x6c, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x50, 0x00, // GNl...........P.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, // ................
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x62, 0x00, // ..............b.
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, // ................
0x00, 0x00, 0x03, 0x0c, 0x00, 0x00, 0x53, 0x56, 0x5f, 0x50, 0x4f, 0x53, 0x49, 0x54, 0x49, 0x4f, // ......SV_POSITIO
0x4e, 0x00, 0x43, 0x4f, 0x4c, 0x4f, 0x52, 0x00, 0x54, 0x45, 0x58, 0x43, 0x4f, 0x4f, 0x52, 0x44, // N.COLOR.TEXCOORD
0x00, 0xab, 0x53, 0x48, 0x44, 0x52, 0x28, 0x01, 0x00, 0x00, 0x40, 0x00, 0x01, 0x00, 0x4a, 0x00, // ..SHDR(...@...J.
0x00, 0x00, 0x59, 0x00, 0x00, 0x04, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, // ..Y...F. .......
0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0xf2, 0x10, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5f, 0x00, // .._..........._.
0x00, 0x03, 0x72, 0x10, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x03, 0x32, 0x10, // ..r......._...2.
0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x04, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, // ......g.... ....
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // ......e.... ....
0x00, 0x00, 0x65, 0x00, 0x00, 0x03, 0x32, 0x20, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x68, 0x00, // ..e...2 ......h.
0x00, 0x02, 0x01, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x08, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, // ......8.........
0x00, 0x00, 0x56, 0x15, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..V.......F. ...
0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, // ......2.........
0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x06, 0x10, // ..F. ...........
0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x32, 0x00, // ......F.......2.
0x00, 0x0a, 0xf2, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..........F. ...
0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0xa6, 0x1a, 0x10, 0x00, 0x01, 0x00, 0x00, 0x00, 0x46, 0x0e, // ..............F.
0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0xf2, 0x20, 0x10, 0x00, 0x00, 0x00, // ........... ....
0x00, 0x00, 0x46, 0x0e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46, 0x8e, 0x20, 0x00, 0x00, 0x00, // ..F.......F. ...
0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0xf2, 0x20, 0x10, 0x00, 0x01, 0x00, // ......6.... ....
0x00, 0x00, 0x46, 0x1e, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x05, 0x32, 0x20, // ..F.......6...2
0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x46, 0x10, 0x10, 0x00, 0x02, 0x00, 0x00, 0x00, 0x3e, 0x00, // ......F.......>.
0x00, 0x01, 0x00, 0x03, 0x05, 0x00, 0x01, 0x00, 0x10, 0x00, 0x40, 0x00, // ..........@.
};
static const uint8_t vs_texture_cube_mtl[751] =
{
0x56, 0x53, 0x48, 0x04, 0x01, 0x83, 0xf2, 0xe1, 0x00, 0x00, 0xe0, 0x02, 0x00, 0x00, 0x75, 0x73, // VSH...........us
0x69, 0x6e, 0x67, 0x20, 0x6e, 0x61, 0x6d, 0x65, 0x73, 0x70, 0x61, 0x63, 0x65, 0x20, 0x6d, 0x65, // ing namespace me
0x74, 0x61, 0x6c, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // tal;.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x7b, // MtlShaderInput {
0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, // . float4 a_colo
0x72, 0x30, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x30, // r0 [[attribute(0
0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x33, 0x20, 0x61, 0x5f, // )]];. float3 a_
0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, // position [[attri
0x62, 0x75, 0x74, 0x65, 0x28, 0x31, 0x29, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, // bute(1)]];. flo
0x61, 0x74, 0x32, 0x20, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, // at2 a_texcoord0
0x5b, 0x5b, 0x61, 0x74, 0x74, 0x72, 0x69, 0x62, 0x75, 0x74, 0x65, 0x28, 0x32, 0x29, 0x5d, 0x5d, // [[attribute(2)]]
0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, // ;.};.struct xlat
0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, // MtlShaderOutput
0x7b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x67, 0x6c, 0x5f, 0x50, 0x6f, // {. float4 gl_Po
0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x5b, 0x5b, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, // sition [[positio
0x6e, 0x5d, 0x5d, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x76, 0x5f, // n]];. float4 v_
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x32, // color0;. float2
0x20, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x3b, 0x0a, 0x7d, 0x3b, // v_texcoord0;.};
0x0a, 0x73, 0x74, 0x72, 0x75, 0x63, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, // .struct xlatMtlS
0x68, 0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x20, 0x7b, 0x0a, 0x20, // haderUniform {.
0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x78, 0x34, 0x20, 0x75, 0x5f, 0x6d, 0x6f, 0x64, 0x65, // float4x4 u_mode
0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x3b, 0x0a, 0x7d, 0x3b, 0x0a, 0x76, 0x65, // lViewProj;.};.ve
0x72, 0x74, 0x65, 0x78, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, 0x64, // rtex xlatMtlShad
0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, // erOutput xlatMtl
0x4d, 0x61, 0x69, 0x6e, 0x20, 0x28, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, 0x61, // Main (xlatMtlSha
0x64, 0x65, 0x72, 0x49, 0x6e, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x20, // derInput _mtl_i
0x5b, 0x5b, 0x73, 0x74, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x5d, 0x5d, 0x2c, 0x20, 0x63, 0x6f, // [[stage_in]], co
0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // nstant xlatMtlSh
0x61, 0x64, 0x65, 0x72, 0x55, 0x6e, 0x69, 0x66, 0x6f, 0x72, 0x6d, 0x26, 0x20, 0x5f, 0x6d, 0x74, // aderUniform& _mt
0x6c, 0x5f, 0x75, 0x20, 0x5b, 0x5b, 0x62, 0x75, 0x66, 0x66, 0x65, 0x72, 0x28, 0x30, 0x29, 0x5d, // l_u [[buffer(0)]
0x5d, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x78, 0x6c, 0x61, 0x74, 0x4d, 0x74, 0x6c, 0x53, 0x68, // ]).{. xlatMtlSh
0x61, 0x64, 0x65, 0x72, 0x4f, 0x75, 0x74, 0x70, 0x75, 0x74, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // aderOutput _mtl_
0x6f, 0x3b, 0x0a, 0x20, 0x20, 0x66, 0x6c, 0x6f, 0x61, 0x74, 0x34, 0x20, 0x74, 0x6d, 0x70, 0x76, // o;. float4 tmpv
0x61, 0x72, 0x5f, 0x31, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, // ar_1;. tmpvar_1
0x2e, 0x77, 0x20, 0x3d, 0x20, 0x31, 0x2e, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x74, 0x6d, 0x70, 0x76, // .w = 1.0;. tmpv
0x61, 0x72, 0x5f, 0x31, 0x2e, 0x78, 0x79, 0x7a, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, // ar_1.xyz = _mtl_
0x69, 0x2e, 0x61, 0x5f, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3b, 0x0a, 0x20, 0x20, // i.a_position;.
0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, 0x69, // _mtl_o.gl_Positi
0x6f, 0x6e, 0x20, 0x3d, 0x20, 0x28, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x75, 0x2e, 0x75, 0x5f, 0x6d, // on = (_mtl_u.u_m
0x6f, 0x64, 0x65, 0x6c, 0x56, 0x69, 0x65, 0x77, 0x50, 0x72, 0x6f, 0x6a, 0x20, 0x2a, 0x20, 0x74, // odelViewProj * t
0x6d, 0x70, 0x76, 0x61, 0x72, 0x5f, 0x31, 0x29, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, // mpvar_1);. _mtl
0x5f, 0x6f, 0x2e, 0x76, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, 0x72, 0x64, 0x30, 0x20, 0x3d, // _o.v_texcoord0 =
0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, 0x61, 0x5f, 0x74, 0x65, 0x78, 0x63, 0x6f, 0x6f, // _mtl_i.a_texcoo
0x72, 0x64, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x2e, 0x76, 0x5f, // rd0;. _mtl_o.v_
0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x20, 0x3d, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x69, 0x2e, // color0 = _mtl_i.
0x61, 0x5f, 0x63, 0x6f, 0x6c, 0x6f, 0x72, 0x30, 0x3b, 0x0a, 0x20, 0x20, 0x72, 0x65, 0x74, 0x75, // a_color0;. retu
0x72, 0x6e, 0x20, 0x5f, 0x6d, 0x74, 0x6c, 0x5f, 0x6f, 0x3b, 0x0a, 0x7d, 0x0a, 0x0a, 0x00, // rn _mtl_o;.}...
};

View File

@ -0,0 +1,16 @@
$input a_position, a_texcoord0, a_color0
$output v_texcoord0, v_color0
/*
* Copyright 2011-2016 Branimir Karadzic. All rights reserved.
* License: http://www.opensource.org/licenses/BSD-2-Clause
*/
#include <bgfx_shader.sh>
void main()
{
gl_Position = mul(u_modelViewProj, vec4(a_position, 1.0) );
v_texcoord0 = a_texcoord0;
v_color0 = a_color0;
}

View File

@ -5,6 +5,8 @@ Base library.
[![Build Status](https://travis-ci.org/bkaradzic/bx.svg?branch=master)](https://travis-ci.org/bkaradzic/bx)
[![Build status](https://ci.appveyor.com/api/projects/status/edras3mltmoy31g5?svg=true)](https://ci.appveyor.com/project/bkaradzic/bx)
[![License](https://img.shields.io/badge/license-BSD--2%20clause-blue.svg)](https://bkaradzic.github.io/bgfx/license.html)
[![Join the chat at https://gitter.im/bkaradzic/bgfx](https://badges.gitter.im/bkaradzic/bgfx.svg)](https://gitter.im/bkaradzic/bgfx)
Contact
-------

View File

@ -10,7 +10,7 @@
#if BX_PLATFORM_ANDROID
# include <android/log.h>
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
extern "C" __declspec(dllimport) void __stdcall OutputDebugStringA(const char* _str);
#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
# if defined(__OBJC__)
@ -55,7 +55,7 @@ namespace bx
# define BX_ANDROID_LOG_TAG ""
# endif // BX_ANDROID_LOG_TAG
__android_log_write(ANDROID_LOG_DEBUG, BX_ANDROID_LOG_TAG, _out);
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360
#elif BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
OutputDebugStringA(_out);
#elif BX_PLATFORM_IOS || BX_PLATFORM_OSX
# if defined(__OBJC__)

View File

@ -8,6 +8,7 @@
#include "bx.h"
#include "debug.h"
#include <sys/stat.h>
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_WINRT
# include <windows.h>
@ -274,6 +275,65 @@ namespace bx
#endif // BX_COMPILER_
}
struct FileInfo
{
enum Enum
{
Regular,
Directory,
Count
};
uint64_t m_size;
Enum m_type;
};
inline bool stat(const char* _filePath, FileInfo& _fileInfo)
{
_fileInfo.m_size = 0;
_fileInfo.m_type = FileInfo::Count;
#if BX_COMPILER_MSVC
struct ::_stat64 st;
int32_t result = ::_stat64(_filePath, &st);
if (0 != result)
{
return false;
}
if (0 != (st.st_mode & _S_IFREG) )
{
_fileInfo.m_type = FileInfo::Regular;
}
else if (0 != (st.st_mode & _S_IFDIR) )
{
_fileInfo.m_type = FileInfo::Directory;
}
#else
struct ::stat st;
int32_t result = ::stat(_filePath, &st);
if (0 != result)
{
return false;
}
if (0 != (st.st_mode & S_IFREG) )
{
_fileInfo.m_type = FileInfo::Regular;
}
else if (0 != (st.st_mode & S_IFDIR) )
{
_fileInfo.m_type = FileInfo::Directory;
}
#endif // BX_COMPILER_MSVC
_fileInfo.m_size = st.st_size;
return true;
}
} // namespace bx
#endif // BX_OS_H_HEADER_GUARD

View File

@ -65,7 +65,7 @@ namespace bx
m_stackSize = _stackSize;
m_running = true;
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360
#if BX_PLATFORM_WINDOWS || BX_PLATFORM_XBOX360 || BX_PLATFORM_XBOXONE
m_handle = ::CreateThread(NULL
, m_stackSize
, (LPTHREAD_START_ROUTINE)threadFunc
@ -103,6 +103,8 @@ namespace bx
result = pthread_create(&m_handle, &attr, &threadFunc, this);
BX_CHECK(0 == result, "pthread_attr_setschedparam failed! %d", result);
#else
# error "Not implemented!"
#endif // BX_PLATFORM_
m_sem.wait();

View File

@ -0,0 +1,5 @@
// BK - MinGW dirent is super broken, using MSVC compatibility one...
#ifndef _DIRENT_H_
# define _DIRENT_H_
# include "../msvc/dirent.h"
#endif // _DIRENT_H_

View File

@ -1,135 +0,0 @@
diff -p Include.orig/d3d9.h Include/d3d9.h
*** Include.orig/d3d9.h 2010-05-19 15:36:57.570669600 -0700
--- Include/d3d9.h 2013-04-07 13:52:57.504138700 -0700
*************** typedef struct IDirect3DQuery9 *LPDIRECT
*** 2022,2029 ****
/*********************
! /* D3D9Ex interfaces
! /*********************/
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex**);
--- 2022,2029 ----
/*********************
! * D3D9Ex interfaces
! *********************/
HRESULT WINAPI Direct3DCreate9Ex(UINT SDKVersion, IDirect3D9Ex**);
diff -p Include.orig/d3d9types.h Include/d3d9types.h
*** Include.orig/d3d9types.h 2010-05-19 15:36:57.601870200 -0700
--- Include/d3d9types.h 2013-04-07 13:52:17.746590200 -0700
***************
*** 19,24 ****
--- 19,25 ----
#include <float.h>
+ #ifdef _MSC_VER
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
***************
*** 26,31 ****
--- 27,33 ----
#if defined(_X86_) || defined(_IA64_)
#pragma pack(4)
#endif
+ #endif // _MSC_VER
// D3DCOLOR is equivalent to D3DFMT_A8R8G8B8
#ifndef D3DCOLOR_DEFINED
*************** typedef struct _D3DAES_CTR_IV
*** 2404,2415 ****
--- 2406,2419 ----
#endif // !D3D_DISABLE_9EX
/* -- D3D9Ex only */
+ #ifdef _MSC_VER
#pragma pack()
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(default:4201)
#endif
+ #endif // _MSC_VER
#endif /* (DIRECT3D_VERSION >= 0x0900) */
#endif /* _d3d9TYPES(P)_H_ */
diff -p Include.orig/D3Dcommon.h Include/D3Dcommon.h
*** Include.orig/D3Dcommon.h 2010-05-19 15:36:57.664271400 -0700
--- Include/D3Dcommon.h 2013-04-07 23:35:07.133638400 -0700
***************
*** 6,12 ****
--- 6,14 ----
/* File created by MIDL compiler version 7.00.0555 */
/* @@MIDL_FILE_HEADING( ) */
+ #ifdef _MSC_VER
#pragma warning( disable: 4049 ) /* more than 64k source lines */
+ #endif // _MSC_VER
/* verify that the <rpcndr.h> version is high enough to compile this file*/
diff -p Include.orig/d3dx9core.h Include/d3dx9core.h
*** Include.orig/d3dx9core.h 2010-05-19 15:36:57.820274400 -0700
--- Include/d3dx9core.h 2013-04-07 23:34:00.976237500 -0700
*************** HRESULT WINAPI
*** 665,681 ****
// TRUE = OpenGL line emulation on.
// FALSE = OpenGL line emulation off.
//
- // OpenGL line: Regular line:
- // *\ *\
- // | \ / \
- // | \ *\ \
- // *\ \ \ \
- // \ \ \ \
- // \ * \ *
- // \ | \ /
- // \| *
- // *
- //
// OnLostDevice, OnResetDevice -
// Call OnLostDevice() on this object before calling Reset() on the
// device, so that this object can release any stateblocks and video
--- 665,670 ----
diff -p Include.orig/d3dx9math.h Include/d3dx9math.h
*** Include.orig/d3dx9math.h 2010-05-19 15:36:57.835874700 -0700
--- Include/d3dx9math.h 2013-04-07 23:31:38.685168800 -0700
***************
*** 12,22 ****
--- 12,24 ----
#ifndef __D3DX9MATH_H__
#define __D3DX9MATH_H__
+ #ifdef _MSC_VER
#include <math.h>
#if _MSC_VER >= 1200
#pragma warning(push)
#endif
#pragma warning(disable:4201) // anonymous unions warning
+ #endif // _MSC_VER
*************** HRESULT WINAPI D3DXSHProjectCubeMap
*** 1786,1796 ****
--- 1788,1800 ----
#include "d3dx9math.inl"
+ #ifdef _MSC_VER
#if _MSC_VER >= 1200
#pragma warning(pop)
#else
#pragma warning(default:4201)
#endif
+ #endif // _MSC_VER
#endif // __D3DX9MATH_H__

View File

@ -27,6 +27,12 @@
#ifndef DIRENT_H
#define DIRENT_H
#ifdef _MSC_VER
# pragma warning(disable:4505) // error C4505: '_wreaddir': unreferenced local function has been removed
#else
# pragma GCC diagnostic ignored "-Wunused-function"
#endif // _MSC_VER
/*
* Define architecture flags so we don't need to include windows.h.
* Avoiding windows.h makes it simpler to use windows sockets in conjunction
@ -143,13 +149,33 @@
* only defined for compatibility. These macros should always return false
* on Windows.
*/
#define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#ifndef S_ISFIFO
# define S_ISFIFO(mode) (((mode) & S_IFMT) == S_IFIFO)
#endif
#ifndef S_ISDIR
# define S_ISDIR(mode) (((mode) & S_IFMT) == S_IFDIR)
#endif
#ifndef S_ISREG
# define S_ISREG(mode) (((mode) & S_IFMT) == S_IFREG)
#endif
#ifndef S_ISLNK
# define S_ISLNK(mode) (((mode) & S_IFMT) == S_IFLNK)
#endif
#ifndef S_ISSOCK
# define S_ISSOCK(mode) (((mode) & S_IFMT) == S_IFSOCK)
#endif
#ifndef S_ISCHR
# define S_ISCHR(mode) (((mode) & S_IFMT) == S_IFCHR)
#endif
#ifndef S_ISBLK
# define S_ISBLK(mode) (((mode) & S_IFMT) == S_IFBLK)
#endif
/* Return the exact length of d_namlen without zero terminator */
#define _D_EXACT_NAMLEN(p) ((p)->d_namlen)
@ -355,11 +381,11 @@ _wreaddir(
if (datap) {
size_t n;
DWORD attr;
/* Pointer to directory entry to return */
entp = &dirp->ent;
/*
/*
* Copy file name as wide-character string. If the file name is too
* long to fit in to the destination buffer, then truncate file name
* to PATH_MAX characters and zero-terminate the buffer.
@ -515,12 +541,12 @@ dirent_next(
return p;
}
/*
/*
* Open directory stream using plain old C-string.
*/
static DIR*
opendir(
const char *dirname)
const char *dirname)
{
struct DIR *dirp;
int error;
@ -552,7 +578,7 @@ opendir(
}
} else {
/*
/*
* Cannot convert file name to wide-character string. This
* occurs if the string contains invalid multi-byte sequences or
* the output buffer is too small to contain the resulting
@ -590,7 +616,7 @@ opendir(
*/
static struct dirent*
readdir(
DIR *dirp)
DIR *dirp)
{
WIN32_FIND_DATAW *datap;
struct dirent *entp;
@ -605,7 +631,7 @@ readdir(
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX, datap->cFileName, PATH_MAX);
/*
/*
* If the file name cannot be represented by a multi-byte string,
* then attempt to use old 8+3 file name. This allows traditional
* Unix-code to access some file names despite of unicode
@ -617,7 +643,7 @@ readdir(
*/
if (error && datap->cAlternateFileName[0] != '\0') {
error = dirent_wcstombs_s(
&n, dirp->ent.d_name, PATH_MAX,
&n, dirp->ent.d_name, PATH_MAX,
datap->cAlternateFileName, PATH_MAX);
}
@ -645,7 +671,7 @@ readdir(
entp->d_reclen = sizeof (struct dirent);
} else {
/*
/*
* Cannot convert file name to multi-byte string so construct
* an errornous directory entry and return that. Note that
* we cannot return NULL as that would stop the processing
@ -673,7 +699,7 @@ readdir(
*/
static int
closedir(
DIR *dirp)
DIR *dirp)
{
int ok;
if (dirp) {
@ -700,7 +726,7 @@ closedir(
*/
static void
rewinddir(
DIR* dirp)
DIR* dirp)
{
/* Rewind wide-character string directory stream */
_wrewinddir (dirp->wdirp);
@ -830,9 +856,7 @@ dirent_set_errno(
#endif
}
#ifdef __cplusplus
}
#endif
#endif /*DIRENT_H*/

View File

@ -339,9 +339,9 @@ function toolchain(_buildDir, _libDir)
location (path.join(_buildDir, "projects", _ACTION .. "-rpi"))
elseif "riscv" == _OPTIONS["gcc"] then
premake.gcc.cc = "/opt/riscv/bin/riscv64-unknown-elf-gcc"
premake.gcc.cxx = "/opt/riscv/bin/riscv64-unknown-elf-g++"
premake.gcc.ar = "/opt/riscv/bin/riscv64-unknown-elf-ar"
premake.gcc.cc = "$(RISCV_DIR)/bin/riscv64-unknown-elf-gcc"
premake.gcc.cxx = "$(RISCV_DIR)/bin/riscv64-unknown-elf-g++"
premake.gcc.ar = "$(RISCV_DIR)/bin/riscv64-unknown-elf-ar"
location (path.join(_buildDir, "projects", _ACTION .. "-riscv"))
end
@ -1139,9 +1139,13 @@ function toolchain(_buildDir, _libDir)
configuration { "riscv" }
targetdir (path.join(_buildDir, "riscv/bin"))
objdir (path.join(_buildDir, "riscv/obj"))
includedirs {
"$(RISCV_DIR)/sysroot/usr/include",
}
buildoptions {
"-Wunused-value",
"-Wundef",
"--sysroot=$(RISCV_DIR)/sysroot",
}
buildoptions_cpp {
"-std=c++0x",

Binary file not shown.

Binary file not shown.

Binary file not shown.