diff --git a/examples/common/entry/entry.cpp b/examples/common/entry/entry.cpp index 5b9314ea..95a64ed8 100644 --- a/examples/common/entry/entry.cpp +++ b/examples/common/entry/entry.cpp @@ -244,3 +244,8 @@ namespace entry } } // namespace entry + +extern "C" bool entry_process_events(uint32_t* _width, uint32_t* _height, uint32_t* _debug, uint32_t* _reset) +{ + return entry::processEvents(*_width, *_height, *_debug, *_reset, NULL); +} diff --git a/include/bgfx.c99.h b/include/bgfx.c99.h new file mode 100644 index 00000000..6d5f1152 --- /dev/null +++ b/include/bgfx.c99.h @@ -0,0 +1,486 @@ +/* + * Copyright 2011-2014 Branimir Karadzic. All rights reserved. + * License: http://www.opensource.org/licenses/BSD-2-Clause + */ + +#ifndef BGFX_C99_H_HEADER_GUARD +#define BGFX_C99_H_HEADER_GUARD + +#include // bool +#include // uint32_t +#include // size_t + +#include "bgfxdefines.h" + +enum bgfx_renderer_type +{ + BGFX_RENDERER_TYPE_NULL, + BGFX_RENDERER_TYPE_DIRECT3D9, + BGFX_RENDERER_TYPE_DIRECT3D11, + BGFX_RENDERER_TYPE_OPENGLES, + BGFX_RENDERER_TYPE_OPENGL, + + BGFX_RENDERER_TYPE_COUNT +}; + +typedef enum bgfx_renderer_type bgfx_renderer_type_t; + +enum bgfx_attrib +{ + BGFX_ATTRIB_POSITION, + BGFX_ATTRIB_NORMAL, + BGFX_ATTRIB_TANGENT, + BGFX_ATTRIB_COLOR0, + BGFX_ATTRIB_COLOR1, + BGFX_ATTRIB_INDICES, + BGFX_ATTRIB_WEIGHT, + BGFX_ATTRIB_TEXCOORD0, + BGFX_ATTRIB_TEXCOORD1, + BGFX_ATTRIB_TEXCOORD2, + BGFX_ATTRIB_TEXCOORD3, + BGFX_ATTRIB_TEXCOORD4, + BGFX_ATTRIB_TEXCOORD5, + BGFX_ATTRIB_TEXCOORD6, + BGFX_ATTRIB_TEXCOORD7, + + BGFX_ATTRIB_COUNT +}; + +typedef enum bgfx_attrib bgfx_attrib_t; + +enum bgfx_attrib_type +{ + BGFX_ATTRIB_TYPE_UINT8, + BGFX_ATTRIB_TYPE_INT16, + BGFX_ATTRIB_TYPE_HALF, + BGFX_ATTRIB_TYPE_FLOAT, + + BGFX_ATTRIB_TYPE_COUNT +}; + +typedef enum bgfx_attrib_type bgfx_attrib_type_t; + +enum bgfx_texture_format +{ + BGFX_TEXTURE_FORMAT_BC1, + BGFX_TEXTURE_FORMAT_BC2, + BGFX_TEXTURE_FORMAT_BC3, + BGFX_TEXTURE_FORMAT_BC4, + BGFX_TEXTURE_FORMAT_BC5, + BGFX_TEXTURE_FORMAT_ETC1, + BGFX_TEXTURE_FORMAT_ETC2, + BGFX_TEXTURE_FORMAT_ETC2A, + BGFX_TEXTURE_FORMAT_ETC2A1, + BGFX_TEXTURE_FORMAT_PTC12, + BGFX_TEXTURE_FORMAT_PTC14, + BGFX_TEXTURE_FORMAT_PTC12A, + BGFX_TEXTURE_FORMAT_PTC14A, + BGFX_TEXTURE_FORMAT_PTC22, + BGFX_TEXTURE_FORMAT_PTC24, + + BGFX_TEXTURE_FORMAT_UNKNOWN, + + BGFX_TEXTURE_FORMAT_R8, + BGFX_TEXTURE_FORMAT_R16, + BGFX_TEXTURE_FORMAT_R16F, + BGFX_TEXTURE_FORMAT_BGRA8, + BGFX_TEXTURE_FORMAT_RGBA16, + BGFX_TEXTURE_FORMAT_RGBA16F, + BGFX_TEXTURE_FORMAT_R5G6B5, + BGFX_TEXTURE_FORMAT_RGBA4, + BGFX_TEXTURE_FORMAT_RGB5A1, + BGFX_TEXTURE_FORMAT_RGB10A2, + + BGFX_TEXTURE_FORMAT_UNKNOWN_DEPTH, + + BGFX_TEXTURE_FORMAT_D16, + BGFX_TEXTURE_FORMAT_D24, + BGFX_TEXTURE_FORMAT_D24S8, + BGFX_TEXTURE_FORMAT_D32, + BGFX_TEXTURE_FORMAT_D16F, + BGFX_TEXTURE_FORMAT_D24F, + BGFX_TEXTURE_FORMAT_D32F, + BGFX_TEXTURE_FORMAT_D0S8, + + BGFX_TEXTURE_FORMAT_COUNT +}; + +typedef enum bgfx_texture_format bgfx_texture_format_t; + +enum bgfx_uniform_type +{ + BGFX_UNIFORM_TYPE_UNIFORM1I, + BGFX_UNIFORM_TYPE_UNIFORM1F, + BGFX_UNIFORM_TYPE_END, + + BGFX_UNIFORM_TYPE_UNIFORM1IV, + BGFX_UNIFORM_TYPE_UNIFORM1FV, + BGFX_UNIFORM_TYPE_UNIFORM2FV, + BGFX_UNIFORM_TYPE_UNIFORM3FV, + BGFX_UNIFORM_TYPE_UNIFORM4FV, + BGFX_UNIFORM_TYPE_UNIFORM3X3FV, + BGFX_UNIFORM_TYPE_UNIFORM4X4FV, + + BGFX_UNIFORM_TYPE_COUNT +}; + +typedef enum bgfx_uniform_type bgfx_uniform_type_t; + +#define BGFX_HANDLE_T(_name) \ + struct _name { uint16_t idx; }; \ + typedef struct _name _name##_t + +BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle); +BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle); +BGFX_HANDLE_T(bgfx_frame_buffer_handle); +BGFX_HANDLE_T(bgfx_index_buffer_handle); +BGFX_HANDLE_T(bgfx_program_handle); +BGFX_HANDLE_T(bgfx_shader_handle); +BGFX_HANDLE_T(bgfx_texture_handle); +BGFX_HANDLE_T(bgfx_uniform_handle); +BGFX_HANDLE_T(bgfx_vertex_buffer_handle); +BGFX_HANDLE_T(bgfx_vertex_decl_handle); + +#undef BGFX_HANDLE_T + +struct bgfx_memory +{ + uint8_t* data; + uint32_t size; +}; + +typedef struct bgfx_memory bgfx_memory_t; + +struct bgfx_vertex_decl +{ + uint32_t hash; + uint16_t stride; + uint16_t offset[BGFX_ATTRIB_COUNT]; + uint8_t attributes[BGFX_ATTRIB_COUNT]; +}; + +typedef struct bgfx_vertex_decl bgfx_vertex_decl_t; + +struct bgfx_transient_index_buffer +{ + uint8_t* data; + uint32_t size; + bgfx_index_buffer_handle_t handle; + uint32_t startIndex; +}; + +typedef struct bgfx_transient_index_buffer bgfx_transient_index_buffer_t; + +struct bgfx_transient_vertex_buffer +{ + uint8_t* data; + uint32_t size; + uint32_t startVertex; + uint16_t stride; + bgfx_vertex_buffer_handle_t handle; + bgfx_vertex_decl_handle_t decl; +}; + +typedef struct bgfx_transient_vertex_buffer bgfx_transient_vertex_buffer_t; + +struct bgfx_instance_data_buffer +{ + uint8_t* data; + uint32_t size; + uint32_t offset; + uint16_t stride; + uint16_t num; + bgfx_vertex_buffer_handle_t handle; +}; + +typedef struct bgfx_instance_data_buffer bgfx_instance_data_buffer_t; + +struct bgfx_texture_info +{ + bgfx_texture_format_t format; + uint32_t storageSize; + uint16_t width; + uint16_t height; + uint16_t depth; + uint8_t numMips; + uint8_t bitsPerPixel; +}; + +typedef struct bgfx_texture_info bgfx_texture_info_t; + +#if defined(__cplusplus) +# define BGFX_C_API extern "C" +#else +# define BGFX_C_API +#endif // defined(__cplusplus) + +/// +BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer); + +/// +BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt); + +/// +BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num); + +/// +BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API void bgfx_init(); + +/// +BGFX_C_API void bgfx_shutdown(); + +/// +BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags); + +/// +BGFX_C_API uint32_t bgfx_frame(); + +/// +BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type(); + +/// +BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size); + +/// +BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size); + +/// +BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size); + +/// +BGFX_C_API void bgfx_set_debug(uint32_t _debug); + +/// +BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small); + +/// +BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...); + +/// +BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle); + +/// +BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle); + +/// +BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num); + +/// +BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle); + +/// +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint16_t _num, const bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle); + +/// +BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num); + +/// +BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride); + +/// +BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices); + +/// +BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num); + +/// +BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl); + +/// +BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint16_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint16_t _numIndices); + +/// +BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(uint32_t _num, uint16_t _stride); + +/// +BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem); + +/// +BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max); + +/// +BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle); + +/// +BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders); + +/// +BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle); + +/// +BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format); + +/// +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info); + +/// +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem); + +/// +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem); + +/// +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch); + +/// +BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem); + +/// +BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch); + +/// +BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle); + +/// +BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags); + +/// +BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures); + +/// +BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle); + +/// +BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num); + +/// +BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle); + +/// +BGFX_C_API void bgfx_set_view_name(uint8_t _id, const char* _name); + +/// +BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + +/// +BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + +/// +BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + +/// +BGFX_C_API void bgfx_set_view_scissor_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + +/// +BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil); + +/// +BGFX_C_API void bgfx_set_view_clear_mask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil); + +/// +BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled); + +/// +BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled); + +/// +BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle); + +/// +BGFX_C_API void bgfx_set_view_frame_buffer_mask(uint32_t _viewMask, bgfx_frame_buffer_handle_t _handle); + +/// +BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj); + +/// +BGFX_C_API void bgfx_set_view_transform_mask(uint32_t _viewMask, const void* _view, const void* _proj); + +/// +BGFX_C_API void bgfx_set_marker(const char* _marker); + +/// +BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba); + +/// +BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil); + +/// +BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height); + +/// +BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache); + +/// +BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num); + +/// +BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num); + +/// +BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num); + +/// +BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); + +/// +BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); + +/// +BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices); + +/// +BGFX_C_API void bgfx_set_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices); + +/// +BGFX_C_API void bgfx_set_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _numVertices); + +/// +BGFX_C_API void bgfx_set_transient_vertex_buffer(const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices); + +/// +BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint16_t _num); + +/// +BGFX_C_API void bgfx_set_program(bgfx_program_handle_t _handle); + +/// +BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags); + +/// +BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, uint32_t _flags); + +/// +BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth); + +/// +BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth); + +/// +BGFX_C_API void bgfx_discard(); + +/// +BGFX_C_API void bgfx_save_screen_shot(const char* _filePath); + +#undef BGFX_C_API + +#endif // BGFX_C99_H_HEADER_GUARD diff --git a/include/bgfx.h b/include/bgfx.h index 2ecc1f5e..b795bbb6 100644 --- a/include/bgfx.h +++ b/include/bgfx.h @@ -9,306 +9,7 @@ #include // uint32_t #include // size_t -/// -#define BGFX_STATE_RGB_WRITE UINT64_C(0x0000000000000001) -#define BGFX_STATE_ALPHA_WRITE UINT64_C(0x0000000000000002) -#define BGFX_STATE_DEPTH_WRITE UINT64_C(0x0000000000000004) - -#define BGFX_STATE_DEPTH_TEST_LESS UINT64_C(0x0000000000000010) -#define BGFX_STATE_DEPTH_TEST_LEQUAL UINT64_C(0x0000000000000020) -#define BGFX_STATE_DEPTH_TEST_EQUAL UINT64_C(0x0000000000000030) -#define BGFX_STATE_DEPTH_TEST_GEQUAL UINT64_C(0x0000000000000040) -#define BGFX_STATE_DEPTH_TEST_GREATER UINT64_C(0x0000000000000050) -#define BGFX_STATE_DEPTH_TEST_NOTEQUAL UINT64_C(0x0000000000000060) -#define BGFX_STATE_DEPTH_TEST_NEVER UINT64_C(0x0000000000000070) -#define BGFX_STATE_DEPTH_TEST_ALWAYS UINT64_C(0x0000000000000080) -#define BGFX_STATE_DEPTH_TEST_SHIFT 4 -#define BGFX_STATE_DEPTH_TEST_MASK UINT64_C(0x00000000000000f0) - -#define BGFX_STATE_BLEND_ZERO UINT64_C(0x0000000000001000) -#define BGFX_STATE_BLEND_ONE UINT64_C(0x0000000000002000) -#define BGFX_STATE_BLEND_SRC_COLOR UINT64_C(0x0000000000003000) -#define BGFX_STATE_BLEND_INV_SRC_COLOR UINT64_C(0x0000000000004000) -#define BGFX_STATE_BLEND_SRC_ALPHA UINT64_C(0x0000000000005000) -#define BGFX_STATE_BLEND_INV_SRC_ALPHA UINT64_C(0x0000000000006000) -#define BGFX_STATE_BLEND_DST_ALPHA UINT64_C(0x0000000000007000) -#define BGFX_STATE_BLEND_INV_DST_ALPHA UINT64_C(0x0000000000008000) -#define BGFX_STATE_BLEND_DST_COLOR UINT64_C(0x0000000000009000) -#define BGFX_STATE_BLEND_INV_DST_COLOR UINT64_C(0x000000000000a000) -#define BGFX_STATE_BLEND_SRC_ALPHA_SAT UINT64_C(0x000000000000b000) -#define BGFX_STATE_BLEND_FACTOR UINT64_C(0x000000000000c000) -#define BGFX_STATE_BLEND_INV_FACTOR UINT64_C(0x000000000000d000) -#define BGFX_STATE_BLEND_SHIFT 12 -#define BGFX_STATE_BLEND_MASK UINT64_C(0x000000000ffff000) - -#define BGFX_STATE_BLEND_EQUATION_SUB UINT64_C(0x0000000010000000) -#define BGFX_STATE_BLEND_EQUATION_REVSUB UINT64_C(0x0000000020000000) -#define BGFX_STATE_BLEND_EQUATION_MIN UINT64_C(0x0000000030000000) -#define BGFX_STATE_BLEND_EQUATION_MAX UINT64_C(0x0000000040000000) -#define BGFX_STATE_BLEND_EQUATION_SHIFT 28 -#define BGFX_STATE_BLEND_EQUATION_MASK UINT64_C(0x00000003f0000000) - -#define BGFX_STATE_BLEND_INDEPENDENT UINT64_C(0x0000000400000000) - -#define BGFX_STATE_CULL_CW UINT64_C(0x0000001000000000) -#define BGFX_STATE_CULL_CCW UINT64_C(0x0000002000000000) -#define BGFX_STATE_CULL_SHIFT 36 -#define BGFX_STATE_CULL_MASK UINT64_C(0x0000003000000000) - -#define BGFX_STATE_ALPHA_REF_SHIFT 40 -#define BGFX_STATE_ALPHA_REF_MASK UINT64_C(0x0000ff0000000000) - -#define BGFX_STATE_PT_TRISTRIP UINT64_C(0x0001000000000000) -#define BGFX_STATE_PT_LINES UINT64_C(0x0002000000000000) -#define BGFX_STATE_PT_POINTS UINT64_C(0x0003000000000000) -#define BGFX_STATE_PT_SHIFT 48 -#define BGFX_STATE_PT_MASK UINT64_C(0x0003000000000000) - -#define BGFX_STATE_POINT_SIZE_SHIFT 52 -#define BGFX_STATE_POINT_SIZE_MASK UINT64_C(0x0ff0000000000000) - -#define BGFX_STATE_MSAA UINT64_C(0x1000000000000000) - -#define BGFX_STATE_RESERVED_MASK UINT64_C(0xe000000000000000) - -#define BGFX_STATE_NONE UINT64_C(0x0000000000000000) -#define BGFX_STATE_MASK UINT64_C(0xffffffffffffffff) -#define BGFX_STATE_DEFAULT (0 \ - | BGFX_STATE_RGB_WRITE \ - | BGFX_STATE_ALPHA_WRITE \ - | BGFX_STATE_DEPTH_TEST_LESS \ - | BGFX_STATE_DEPTH_WRITE \ - | BGFX_STATE_CULL_CW \ - | BGFX_STATE_MSAA \ - ) - -#define BGFX_STATE_ALPHA_REF(_ref) ( (uint64_t(_ref)<>BGFX_STATE_BLEND_SHIFT) \ - | ( uint32_t( (_dst)>>BGFX_STATE_BLEND_SHIFT)<<4) ) \ - ) - -#define BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) (0 \ - | BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) \ - | ( uint32_t( (_equation)>>BGFX_STATE_BLEND_EQUATION_SHIFT)<<8) \ - ) - -#define BGFX_STATE_BLEND_FUNC_RT_1(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<< 0) -#define BGFX_STATE_BLEND_FUNC_RT_2(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<11) -#define BGFX_STATE_BLEND_FUNC_RT_3(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<22) - -#define BGFX_STATE_BLEND_FUNC_RT_1E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<< 0) -#define BGFX_STATE_BLEND_FUNC_RT_2E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<11) -#define BGFX_STATE_BLEND_FUNC_RT_3E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<22) - -/// -#define BGFX_STENCIL_FUNC_REF_SHIFT 0 -#define BGFX_STENCIL_FUNC_REF_MASK UINT32_C(0x000000ff) -#define BGFX_STENCIL_FUNC_RMASK_SHIFT 8 -#define BGFX_STENCIL_FUNC_RMASK_MASK UINT32_C(0x0000ff00) - -#define BGFX_STENCIL_TEST_LESS UINT32_C(0x00010000) -#define BGFX_STENCIL_TEST_LEQUAL UINT32_C(0x00020000) -#define BGFX_STENCIL_TEST_EQUAL UINT32_C(0x00030000) -#define BGFX_STENCIL_TEST_GEQUAL UINT32_C(0x00040000) -#define BGFX_STENCIL_TEST_GREATER UINT32_C(0x00050000) -#define BGFX_STENCIL_TEST_NOTEQUAL UINT32_C(0x00060000) -#define BGFX_STENCIL_TEST_NEVER UINT32_C(0x00070000) -#define BGFX_STENCIL_TEST_ALWAYS UINT32_C(0x00080000) -#define BGFX_STENCIL_TEST_SHIFT 16 -#define BGFX_STENCIL_TEST_MASK UINT32_C(0x000f0000) - -#define BGFX_STENCIL_OP_FAIL_S_ZERO UINT32_C(0x00000000) -#define BGFX_STENCIL_OP_FAIL_S_KEEP UINT32_C(0x00100000) -#define BGFX_STENCIL_OP_FAIL_S_REPLACE UINT32_C(0x00200000) -#define BGFX_STENCIL_OP_FAIL_S_INCR UINT32_C(0x00300000) -#define BGFX_STENCIL_OP_FAIL_S_INCRSAT UINT32_C(0x00400000) -#define BGFX_STENCIL_OP_FAIL_S_DECR UINT32_C(0x00500000) -#define BGFX_STENCIL_OP_FAIL_S_DECRSAT UINT32_C(0x00600000) -#define BGFX_STENCIL_OP_FAIL_S_INVERT UINT32_C(0x00700000) -#define BGFX_STENCIL_OP_FAIL_S_SHIFT 20 -#define BGFX_STENCIL_OP_FAIL_S_MASK UINT32_C(0x00f00000) - -#define BGFX_STENCIL_OP_FAIL_Z_ZERO UINT32_C(0x00000000) -#define BGFX_STENCIL_OP_FAIL_Z_KEEP UINT32_C(0x01000000) -#define BGFX_STENCIL_OP_FAIL_Z_REPLACE UINT32_C(0x02000000) -#define BGFX_STENCIL_OP_FAIL_Z_INCR UINT32_C(0x03000000) -#define BGFX_STENCIL_OP_FAIL_Z_INCRSAT UINT32_C(0x04000000) -#define BGFX_STENCIL_OP_FAIL_Z_DECR UINT32_C(0x05000000) -#define BGFX_STENCIL_OP_FAIL_Z_DECRSAT UINT32_C(0x06000000) -#define BGFX_STENCIL_OP_FAIL_Z_INVERT UINT32_C(0x07000000) -#define BGFX_STENCIL_OP_FAIL_Z_SHIFT 24 -#define BGFX_STENCIL_OP_FAIL_Z_MASK UINT32_C(0x0f000000) - -#define BGFX_STENCIL_OP_PASS_Z_ZERO UINT32_C(0x00000000) -#define BGFX_STENCIL_OP_PASS_Z_KEEP UINT32_C(0x10000000) -#define BGFX_STENCIL_OP_PASS_Z_REPLACE UINT32_C(0x20000000) -#define BGFX_STENCIL_OP_PASS_Z_INCR UINT32_C(0x30000000) -#define BGFX_STENCIL_OP_PASS_Z_INCRSAT UINT32_C(0x40000000) -#define BGFX_STENCIL_OP_PASS_Z_DECR UINT32_C(0x50000000) -#define BGFX_STENCIL_OP_PASS_Z_DECRSAT UINT32_C(0x60000000) -#define BGFX_STENCIL_OP_PASS_Z_INVERT UINT32_C(0x70000000) -#define BGFX_STENCIL_OP_PASS_Z_SHIFT 28 -#define BGFX_STENCIL_OP_PASS_Z_MASK UINT32_C(0xf0000000) - -#define BGFX_STENCIL_NONE UINT32_C(0x00000000) -#define BGFX_STENCIL_MASK UINT32_C(0xffffffff) -#define BGFX_STENCIL_DEFAULT UINT32_C(0x00000000) - -#define BGFX_STENCIL_FUNC_REF(_ref) ( (uint32_t(_ref)<>BGFX_STATE_BLEND_SHIFT) \ + | ( uint32_t( (_dst)>>BGFX_STATE_BLEND_SHIFT)<<4) ) \ + ) + +#define BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation) (0 \ + | BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst) \ + | ( uint32_t( (_equation)>>BGFX_STATE_BLEND_EQUATION_SHIFT)<<8) \ + ) + +#define BGFX_STATE_BLEND_FUNC_RT_1(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<< 0) +#define BGFX_STATE_BLEND_FUNC_RT_2(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<11) +#define BGFX_STATE_BLEND_FUNC_RT_3(_src, _dst) (BGFX_STATE_BLEND_FUNC_RT_x(_src, _dst)<<22) + +#define BGFX_STATE_BLEND_FUNC_RT_1E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<< 0) +#define BGFX_STATE_BLEND_FUNC_RT_2E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<11) +#define BGFX_STATE_BLEND_FUNC_RT_3E(_src, _dst, _equation) (BGFX_STATE_BLEND_FUNC_RT_xE(_src, _dst, _equation)<<22) + +/// +#define BGFX_STENCIL_FUNC_REF_SHIFT 0 +#define BGFX_STENCIL_FUNC_REF_MASK UINT32_C(0x000000ff) +#define BGFX_STENCIL_FUNC_RMASK_SHIFT 8 +#define BGFX_STENCIL_FUNC_RMASK_MASK UINT32_C(0x0000ff00) + +#define BGFX_STENCIL_TEST_LESS UINT32_C(0x00010000) +#define BGFX_STENCIL_TEST_LEQUAL UINT32_C(0x00020000) +#define BGFX_STENCIL_TEST_EQUAL UINT32_C(0x00030000) +#define BGFX_STENCIL_TEST_GEQUAL UINT32_C(0x00040000) +#define BGFX_STENCIL_TEST_GREATER UINT32_C(0x00050000) +#define BGFX_STENCIL_TEST_NOTEQUAL UINT32_C(0x00060000) +#define BGFX_STENCIL_TEST_NEVER UINT32_C(0x00070000) +#define BGFX_STENCIL_TEST_ALWAYS UINT32_C(0x00080000) +#define BGFX_STENCIL_TEST_SHIFT 16 +#define BGFX_STENCIL_TEST_MASK UINT32_C(0x000f0000) + +#define BGFX_STENCIL_OP_FAIL_S_ZERO UINT32_C(0x00000000) +#define BGFX_STENCIL_OP_FAIL_S_KEEP UINT32_C(0x00100000) +#define BGFX_STENCIL_OP_FAIL_S_REPLACE UINT32_C(0x00200000) +#define BGFX_STENCIL_OP_FAIL_S_INCR UINT32_C(0x00300000) +#define BGFX_STENCIL_OP_FAIL_S_INCRSAT UINT32_C(0x00400000) +#define BGFX_STENCIL_OP_FAIL_S_DECR UINT32_C(0x00500000) +#define BGFX_STENCIL_OP_FAIL_S_DECRSAT UINT32_C(0x00600000) +#define BGFX_STENCIL_OP_FAIL_S_INVERT UINT32_C(0x00700000) +#define BGFX_STENCIL_OP_FAIL_S_SHIFT 20 +#define BGFX_STENCIL_OP_FAIL_S_MASK UINT32_C(0x00f00000) + +#define BGFX_STENCIL_OP_FAIL_Z_ZERO UINT32_C(0x00000000) +#define BGFX_STENCIL_OP_FAIL_Z_KEEP UINT32_C(0x01000000) +#define BGFX_STENCIL_OP_FAIL_Z_REPLACE UINT32_C(0x02000000) +#define BGFX_STENCIL_OP_FAIL_Z_INCR UINT32_C(0x03000000) +#define BGFX_STENCIL_OP_FAIL_Z_INCRSAT UINT32_C(0x04000000) +#define BGFX_STENCIL_OP_FAIL_Z_DECR UINT32_C(0x05000000) +#define BGFX_STENCIL_OP_FAIL_Z_DECRSAT UINT32_C(0x06000000) +#define BGFX_STENCIL_OP_FAIL_Z_INVERT UINT32_C(0x07000000) +#define BGFX_STENCIL_OP_FAIL_Z_SHIFT 24 +#define BGFX_STENCIL_OP_FAIL_Z_MASK UINT32_C(0x0f000000) + +#define BGFX_STENCIL_OP_PASS_Z_ZERO UINT32_C(0x00000000) +#define BGFX_STENCIL_OP_PASS_Z_KEEP UINT32_C(0x10000000) +#define BGFX_STENCIL_OP_PASS_Z_REPLACE UINT32_C(0x20000000) +#define BGFX_STENCIL_OP_PASS_Z_INCR UINT32_C(0x30000000) +#define BGFX_STENCIL_OP_PASS_Z_INCRSAT UINT32_C(0x40000000) +#define BGFX_STENCIL_OP_PASS_Z_DECR UINT32_C(0x50000000) +#define BGFX_STENCIL_OP_PASS_Z_DECRSAT UINT32_C(0x60000000) +#define BGFX_STENCIL_OP_PASS_Z_INVERT UINT32_C(0x70000000) +#define BGFX_STENCIL_OP_PASS_Z_SHIFT 28 +#define BGFX_STENCIL_OP_PASS_Z_MASK UINT32_C(0xf0000000) + +#define BGFX_STENCIL_NONE UINT32_C(0x00000000) +#define BGFX_STENCIL_MASK UINT32_C(0xffffffff) +#define BGFX_STENCIL_DEFAULT UINT32_C(0x00000000) + +#define BGFX_STENCIL_FUNC_REF(_ref) ( (uint32_t(_ref)<m_scissor, m_scissor, sizeof(m_scissor) ); memcpy(m_submit->m_view, m_view, sizeof(m_view) ); memcpy(m_submit->m_proj, m_proj, sizeof(m_proj) ); - memcpy(m_submit->m_other, m_other, sizeof(m_other) ); m_submit->finish(); Frame* temp = m_render; @@ -1265,7 +1262,8 @@ namespace bgfx uint32_t getWindowsVersion() { #if BX_PLATFORM_WINDOWS - OSVERSIONINFOEXA ovi = {}; + OSVERSIONINFOEXA ovi; + memset(&ovi, 0, sizeof(ovi) ); ovi.dwOSVersionInfoSize = sizeof(ovi); if (!GetVersionExA( (LPOSVERSIONINFOA)&ovi) ) { @@ -1920,6 +1918,11 @@ again: s_ctx->dbgTextClear(_attr, _small); } + void dbgTextPrintfVargs(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, va_list _argList) + { + s_ctx->dbgTextPrintfVargs(_x, _y, _attr, _format, _argList); + } + void dbgTextPrintf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...) { BGFX_CHECK_MAIN_THREAD(); @@ -2438,16 +2441,16 @@ again: s_ctx->setViewFrameBufferMask(_mask, _handle); } - void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other) + void setViewTransform(uint8_t _id, const void* _view, const void* _proj) { BGFX_CHECK_MAIN_THREAD(); - s_ctx->setViewTransform(_id, _view, _proj, _other); + s_ctx->setViewTransform(_id, _view, _proj); } - void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other) + void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj) { BGFX_CHECK_MAIN_THREAD(); - s_ctx->setViewTransformMask(_viewMask, _view, _proj, _other); + s_ctx->setViewTransformMask(_viewMask, _view, _proj); } void setMarker(const char* _marker) @@ -2599,4 +2602,546 @@ again: BGFX_CHECK_MAIN_THREAD(); s_ctx->saveScreenShot(_filePath); } +} // namespace bgfx + +#include + +BX_STATIC_ASSERT(bgfx::RendererType::Count == bgfx::RendererType::Enum(BGFX_RENDERER_TYPE_COUNT) ); +BX_STATIC_ASSERT(bgfx::Attrib::Count == bgfx::Attrib::Enum(BGFX_ATTRIB_COUNT) ); +BX_STATIC_ASSERT(bgfx::AttribType::Count == bgfx::AttribType::Enum(BGFX_ATTRIB_TYPE_COUNT) ); +BX_STATIC_ASSERT(bgfx::TextureFormat::Count == bgfx::TextureFormat::Enum(BGFX_TEXTURE_FORMAT_COUNT) ); +BX_STATIC_ASSERT(bgfx::UniformType::Count == bgfx::UniformType::Enum(BGFX_UNIFORM_TYPE_COUNT) ); + +BX_STATIC_ASSERT(sizeof(bgfx::Memory) == sizeof(bgfx_memory_t) ); +BX_STATIC_ASSERT(sizeof(bgfx::VertexDecl) == sizeof(bgfx_vertex_decl_t) ); +BX_STATIC_ASSERT(sizeof(bgfx::TransientIndexBuffer) == sizeof(bgfx_transient_index_buffer_t) ); +BX_STATIC_ASSERT(sizeof(bgfx::TransientVertexBuffer) == sizeof(bgfx_transient_vertex_buffer_t) ); +BX_STATIC_ASSERT(sizeof(bgfx::InstanceDataBuffer) == sizeof(bgfx_instance_data_buffer_t) ); +BX_STATIC_ASSERT(sizeof(bgfx::TextureInfo) == sizeof(bgfx_texture_info_t) ); + +#define BGFX_C_API extern "C" + +BGFX_C_API void bgfx_vertex_decl_begin(bgfx_vertex_decl_t* _decl, bgfx_renderer_type_t _renderer) +{ + bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl; + decl->begin(bgfx::RendererType::Enum(_renderer) ); +} + +BGFX_C_API void bgfx_vertex_decl_add(bgfx_vertex_decl_t* _decl, bgfx_attrib_t _attrib, uint8_t _num, bgfx_attrib_type_t _type, bool _normalized, bool _asInt) +{ + bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl; + decl->add(bgfx::Attrib::Enum(_attrib) + , _num + , bgfx::AttribType::Enum(_type) + , _normalized + , _asInt + ); +} + +BGFX_C_API void bgfx_vertex_decl_skip(bgfx_vertex_decl_t* _decl, uint8_t _num) +{ + bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl; + decl->skip(_num); +} + +BGFX_C_API void bgfx_vertex_decl_end(bgfx_vertex_decl_t* _decl) +{ + bgfx::VertexDecl* decl = (bgfx::VertexDecl*)_decl; + decl->end(); +} + +BGFX_C_API void bgfx_init() +{ + return bgfx::init(); +} + +BGFX_C_API void bgfx_shutdown() +{ + return bgfx::shutdown(); +} + +BGFX_C_API void bgfx_reset(uint32_t _width, uint32_t _height, uint32_t _flags) +{ + bgfx::reset(_width, _height, _flags); +} + +BGFX_C_API uint32_t bgfx_frame() +{ + return bgfx::frame(); +} + +BGFX_C_API bgfx_renderer_type_t bgfx_get_renderer_type() +{ + return bgfx_renderer_type_t(bgfx::getRendererType() ); +} + +BGFX_C_API const bgfx_memory_t* bgfx_alloc(uint32_t _size) +{ + return (const bgfx_memory_t*)bgfx::alloc(_size); +} + +BGFX_C_API const bgfx_memory_t* bgfx_copy(const void* _data, uint32_t _size) +{ + return (const bgfx_memory_t*)bgfx::copy(_data, _size); +} + +BGFX_C_API const bgfx_memory_t* bgfx_make_ref(const void* _data, uint32_t _size) +{ + return (const bgfx_memory_t*)bgfx::makeRef(_data, _size); +} + +BGFX_C_API void bgfx_set_debug(uint32_t _debug) +{ + bgfx::setDebug(_debug); +} + +BGFX_C_API void bgfx_dbg_text_clear(uint8_t _attr, bool _small) +{ + bgfx::dbgTextClear(_attr, _small); +} + +BGFX_C_API void bgfx_dbg_text_printf(uint16_t _x, uint16_t _y, uint8_t _attr, const char* _format, ...) +{ + va_list argList; + va_start(argList, _format); + bgfx::dbgTextPrintfVargs(_x, _y, _attr, _format, argList); + va_end(argList); +} + +BGFX_C_API bgfx_index_buffer_handle_t bgfx_create_index_buffer(const bgfx_memory_t* _mem) +{ + union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle; + handle.cpp = bgfx::createIndexBuffer( (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API void bgfx_destroy_index_buffer(bgfx_index_buffer_handle_t _handle) +{ + union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle }; + bgfx::destroyIndexBuffer(handle.cpp); +} + +BGFX_C_API bgfx_vertex_buffer_handle_t bgfx_create_vertex_buffer(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle; + handle.cpp = bgfx::createVertexBuffer( (const bgfx::Memory*)_mem, decl); + return handle.c; +} + +BGFX_C_API void bgfx_destroy_vertex_buffer(bgfx_vertex_buffer_handle_t _handle) +{ + union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle }; + bgfx::destroyVertexBuffer(handle.cpp); +} + +BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer(uint32_t _num) +{ + union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle; + handle.cpp = bgfx::createDynamicIndexBuffer(_num); + return handle.c; +} + +BGFX_C_API bgfx_dynamic_index_buffer_handle_t bgfx_create_dynamic_index_buffer_mem(const bgfx_memory_t* _mem) +{ + union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle; + handle.cpp = bgfx::createDynamicIndexBuffer( (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API void bgfx_update_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, const bgfx_memory_t* _mem) +{ + union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle }; + bgfx::updateDynamicIndexBuffer(handle.cpp, (const bgfx::Memory*)_mem); +} + +BGFX_C_API void bgfx_destroy_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle) +{ + union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle }; + bgfx::destroyDynamicIndexBuffer(handle.cpp); +} + +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer(uint16_t _num, const bgfx_vertex_decl_t* _decl) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle; + handle.cpp = bgfx::createDynamicVertexBuffer(_num, decl); + return handle.c; +} + +BGFX_C_API bgfx_dynamic_vertex_buffer_handle_t bgfx_create_dynamic_vertex_buffer_mem(const bgfx_memory_t* _mem, const bgfx_vertex_decl_t* _decl) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle; + handle.cpp = bgfx::createDynamicVertexBuffer( (const bgfx::Memory*)_mem, decl); + return handle.c; +} + +BGFX_C_API void bgfx_update_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, const bgfx_memory_t* _mem) +{ + union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle }; + bgfx::updateDynamicVertexBuffer(handle.cpp, (const bgfx::Memory*)_mem); +} + +BGFX_C_API void bgfx_destroy_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle) +{ + union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle }; + bgfx::destroyDynamicVertexBuffer(handle.cpp); +} + +BGFX_C_API bool bgfx_check_avail_transient_index_buffer(uint32_t _num) +{ + return bgfx::checkAvailTransientIndexBuffer(_num); +} + +BGFX_C_API bool bgfx_check_avail_transient_vertex_buffer(uint32_t _num, const bgfx_vertex_decl_t* _decl) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + return bgfx::checkAvailTransientVertexBuffer(_num, decl); +} + +BGFX_C_API bool bgfx_check_avail_instance_data_buffer(uint32_t _num, uint16_t _stride) +{ + return bgfx::checkAvailInstanceDataBuffer(_num, _stride); +} + +BGFX_C_API bool bgfx_check_avail_transient_buffers(uint32_t _numVertices, const bgfx_vertex_decl_t* _decl, uint32_t _numIndices) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + return bgfx::checkAvailTransientBuffers(_numVertices, decl, _numIndices); +} + +BGFX_C_API void bgfx_alloc_transient_index_buffer(bgfx_transient_index_buffer_t* _tib, uint32_t _num) +{ + bgfx::allocTransientIndexBuffer( (bgfx::TransientIndexBuffer*)_tib, _num); +} + +BGFX_C_API void bgfx_alloc_transient_vertex_buffer(bgfx_transient_vertex_buffer_t* _tvb, uint32_t _num, const bgfx_vertex_decl_t* _decl) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + bgfx::allocTransientVertexBuffer( (bgfx::TransientVertexBuffer*)_tvb, _num, decl); +} + +BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tvb, const bgfx_vertex_decl_t* _decl, uint16_t _numVertices, bgfx_transient_index_buffer_t* _tib, uint16_t _numIndices) +{ + const bgfx::VertexDecl& decl = *(const bgfx::VertexDecl*)_decl; + return bgfx::allocTransientBuffers( (bgfx::TransientVertexBuffer*)_tvb, decl, _numVertices, (bgfx::TransientIndexBuffer*)_tib, _numIndices); +} + +BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(uint32_t _num, uint16_t _stride) +{ + return (bgfx_instance_data_buffer_t*)bgfx::allocInstanceDataBuffer(_num, _stride); +} + +BGFX_C_API bgfx_shader_handle_t bgfx_create_shader(const bgfx_memory_t* _mem) +{ + union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle; + handle.cpp = bgfx::createShader( (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API uint16_t bgfx_get_shader_uniforms(bgfx_shader_handle_t _handle, bgfx_uniform_handle_t* _uniforms, uint16_t _max) +{ + union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle }; + return bgfx::getShaderUniforms(handle.cpp, (bgfx::UniformHandle*)_uniforms, _max); +} + +BGFX_C_API void bgfx_destroy_shader(bgfx_shader_handle_t _handle) +{ + union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } handle = { _handle }; + bgfx::destroyShader(handle.cpp); +} + +BGFX_C_API bgfx_program_handle_t bgfx_create_program(bgfx_shader_handle_t _vsh, bgfx_shader_handle_t _fsh, bool _destroyShaders) +{ + union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } vsh = { _vsh }; + union { bgfx_shader_handle_t c; bgfx::ShaderHandle cpp; } fsh = { _fsh }; + union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle; + handle.cpp = bgfx::createProgram(vsh.cpp, fsh.cpp, _destroyShaders); + return handle.c; +} + +BGFX_C_API void bgfx_destroy_program(bgfx_program_handle_t _handle) +{ + union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle }; + bgfx::destroyProgram(handle.cpp); +} + +BGFX_C_API void bgfx_calc_texture_size(bgfx_texture_info_t* _info, uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format) +{ + bgfx::TextureInfo& info = *(bgfx::TextureInfo*)_info; + bgfx::calcTextureSize(info, _width, _height, _depth, _numMips, bgfx::TextureFormat::Enum(_format) ); +} + +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture(const bgfx_memory_t* _mem, uint32_t _flags, uint8_t _skip, bgfx_texture_info_t* _info) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle; + bgfx::TextureInfo* info = (bgfx::TextureInfo*)_info; + handle.cpp = bgfx::createTexture( (const bgfx::Memory*)_mem, _flags, _skip, info); + return handle.c; +} + +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_2d(uint16_t _width, uint16_t _height, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle; + handle.cpp = bgfx::createTexture2D(_width, _height, _numMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_3d(uint16_t _width, uint16_t _height, uint16_t _depth, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle; + handle.cpp = bgfx::createTexture3D(_width, _height, _depth, _numMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API bgfx_texture_handle_t bgfx_create_texture_cube(uint16_t _size, uint8_t _numMips, bgfx_texture_format_t _format, uint32_t _flags, const bgfx_memory_t* _mem) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle; + handle.cpp = bgfx::createTextureCube(_size, _numMips, bgfx::TextureFormat::Enum(_format), _flags, (const bgfx::Memory*)_mem); + return handle.c; +} + +BGFX_C_API void bgfx_update_texture_2d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle }; + bgfx::updateTexture2D(handle.cpp, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch); +} + +BGFX_C_API void bgfx_update_texture_3d(bgfx_texture_handle_t _handle, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _z, uint16_t _width, uint16_t _height, uint16_t _depth, const bgfx_memory_t* _mem) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle }; + bgfx::updateTexture3D(handle.cpp, _mip, _x, _y, _z, _width, _height, _depth, (const bgfx::Memory*)_mem); +} + +BGFX_C_API void bgfx_update_texture_cube(bgfx_texture_handle_t _handle, uint8_t _side, uint8_t _mip, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height, const bgfx_memory_t* _mem, uint16_t _pitch) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle }; + bgfx::updateTextureCube(handle.cpp, _side, _mip, _x, _y, _width, _height, (const bgfx::Memory*)_mem, _pitch); +} + +BGFX_C_API void bgfx_destroy_texture(bgfx_texture_handle_t _handle) +{ + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle }; + bgfx::destroyTexture(handle.cpp); +} + +BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer(uint16_t _width, uint16_t _height, bgfx_texture_format_t _format, uint32_t _textureFlags) +{ + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle; + handle.cpp = bgfx::createFrameBuffer(_width, _height, bgfx::TextureFormat::Enum(_format), _textureFlags); + return handle.c; +} + +BGFX_C_API bgfx_frame_buffer_handle_t bgfx_create_frame_buffer_from_handles(uint8_t _num, bgfx_texture_handle_t* _handles, bool _destroyTextures) +{ + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle; + handle.cpp = bgfx::createFrameBuffer(_num, (bgfx::TextureHandle*)_handles, _destroyTextures); + return handle.c; +} + +BGFX_C_API void bgfx_destroy_frame_buffer(bgfx_frame_buffer_handle_t _handle) +{ + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle }; + bgfx::destroyFrameBuffer(handle.cpp); +} + +BGFX_C_API bgfx_uniform_handle_t bgfx_create_uniform(const char* _name, bgfx_uniform_type_t _type, uint16_t _num) +{ + union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle; + handle.cpp = bgfx::createUniform(_name, bgfx::UniformType::Enum(_type), _num); + return handle.c; +} + +BGFX_C_API void bgfx_destroy_uniform(bgfx_uniform_handle_t _handle) +{ + union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle }; + bgfx::destroyUniform(handle.cpp); +} + +BGFX_C_API void bgfx_set_view_name(uint8_t _id, const char* _name) +{ + bgfx::setViewName(_id, _name); +} + +BGFX_C_API void bgfx_set_view_rect(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + bgfx::setViewRect(_id, _x, _y, _width, _height); +} + +BGFX_C_API void bgfx_set_view_rect_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + bgfx::setViewRectMask(_viewMask, _x, _y, _width, _height); +} + +BGFX_C_API void bgfx_set_view_scissor(uint8_t _id, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + bgfx::setViewScissor(_id, _x, _y, _width, _height); +} + +BGFX_C_API void bgfx_set_view_scissor_mask(uint32_t _viewMask, uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + bgfx::setViewScissorMask(_viewMask, _x, _y, _width, _height); +} + +BGFX_C_API void bgfx_set_view_clear(uint8_t _id, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) +{ + bgfx::setViewClear(_id, _flags, _rgba, _depth, _stencil); +} + +BGFX_C_API void bgfx_set_view_clear_mask(uint32_t _viewMask, uint8_t _flags, uint32_t _rgba, float _depth, uint8_t _stencil) +{ + bgfx::setViewClearMask(_viewMask, _flags, _rgba, _depth, _stencil); +} + +BGFX_C_API void bgfx_set_view_seq(uint8_t _id, bool _enabled) +{ + bgfx::setViewSeq(_id, _enabled); +} + +BGFX_C_API void bgfx_set_view_seq_mask(uint32_t _viewMask, bool _enabled) +{ + bgfx::setViewSeqMask(_viewMask, _enabled); +} + +BGFX_C_API void bgfx_set_view_frame_buffer(uint8_t _id, bgfx_frame_buffer_handle_t _handle) +{ + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle }; + bgfx::setViewFrameBuffer(_id, handle.cpp); +} + +BGFX_C_API void bgfx_set_view_frame_buffer_mask(uint32_t _viewMask, bgfx_frame_buffer_handle_t _handle) +{ + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle }; + bgfx::setViewFrameBufferMask(_viewMask, handle.cpp); +} + +BGFX_C_API void bgfx_set_view_transform(uint8_t _id, const void* _view, const void* _proj) +{ + bgfx::setViewTransform(_id, _view, _proj); +} + +BGFX_C_API void bgfx_set_view_transform_mask(uint32_t _viewMask, const void* _view, const void* _proj) +{ + bgfx::setViewTransformMask(_viewMask, _view, _proj); +} + +BGFX_C_API void bgfx_set_marker(const char* _marker) +{ + bgfx::setMarker(_marker); +} + +BGFX_C_API void bgfx_set_state(uint64_t _state, uint32_t _rgba) +{ + bgfx::setState(_state, _rgba); +} + +BGFX_C_API void bgfx_set_stencil(uint32_t _fstencil, uint32_t _bstencil) +{ + bgfx::setStencil(_fstencil, _bstencil); +} + +BGFX_C_API uint16_t bgfx_set_scissor(uint16_t _x, uint16_t _y, uint16_t _width, uint16_t _height) +{ + return bgfx::setScissor(_x, _y, _width, _height); +} + +BGFX_C_API void bgfx_set_scissor_cached(uint16_t _cache) +{ + bgfx::setScissor(_cache); +} + +BGFX_C_API uint32_t bgfx_set_transform(const void* _mtx, uint16_t _num) +{ + return bgfx::setTransform(_mtx, _num); +} + +BGFX_C_API void bgfx_set_transform_cached(uint32_t _cache, uint16_t _num) +{ + bgfx::setTransform(_cache, _num); +} + +BGFX_C_API void bgfx_set_uniform(bgfx_uniform_handle_t _handle, const void* _value, uint16_t _num) +{ + union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } handle = { _handle }; + bgfx::setUniform(handle.cpp, _value, _num); +} + +BGFX_C_API void bgfx_set_index_buffer(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices) +{ + union { bgfx_index_buffer_handle_t c; bgfx::IndexBufferHandle cpp; } handle = { _handle }; + bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices); +} + +BGFX_C_API void bgfx_set_dynamic_index_buffer(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices) +{ + union { bgfx_dynamic_index_buffer_handle_t c; bgfx::DynamicIndexBufferHandle cpp; } handle = { _handle }; + bgfx::setIndexBuffer(handle.cpp, _firstIndex, _numIndices); +} + +BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices) +{ + bgfx::setIndexBuffer( (const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices); +} + +BGFX_C_API void bgfx_set_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices) +{ + union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle }; + bgfx::setVertexBuffer(handle.cpp, _startVertex, _numVertices); +} + +BGFX_C_API void bgfx_set_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _numVertices) +{ + union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle }; + bgfx::setVertexBuffer(handle.cpp, _numVertices); +} + +BGFX_C_API void bgfx_set_transient_vertex_buffer(const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices) +{ + bgfx::setVertexBuffer( (const bgfx::TransientVertexBuffer*)_tvb, _startVertex, _numVertices); +} + +BGFX_C_API void bgfx_set_instance_data_buffer(const bgfx_instance_data_buffer_t* _idb, uint16_t _num) +{ + bgfx::setInstanceDataBuffer( (const bgfx::InstanceDataBuffer*)_idb, _num); +} + +BGFX_C_API void bgfx_set_program(bgfx_program_handle_t _handle) +{ + union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle }; + bgfx::setProgram(handle.cpp); +} + +BGFX_C_API void bgfx_set_texture(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint32_t _flags) +{ + union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler }; + union { bgfx_texture_handle_t c; bgfx::TextureHandle cpp; } handle = { _handle }; + bgfx::setTexture(_stage, sampler.cpp, handle.cpp, _flags); +} + +BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_frame_buffer_handle_t _handle, uint8_t _attachment, uint32_t _flags) +{ + union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler }; + union { bgfx_frame_buffer_handle_t c; bgfx::FrameBufferHandle cpp; } handle = { _handle }; + bgfx::setTexture(_stage, sampler.cpp, handle.cpp, _attachment, _flags); +} + +BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth) +{ + return bgfx::submit(_id, _depth); +} + +BGFX_C_API uint32_t bgfx_submit_mask(uint32_t _viewMask, int32_t _depth) +{ + return bgfx::submitMask(_viewMask, _depth); +} + +BGFX_C_API void bgfx_discard() +{ + bgfx::discard(); +} + +BGFX_C_API void bgfx_save_screen_shot(const char* _filePath) +{ + bgfx::saveScreenShot(_filePath); } diff --git a/src/bgfx_p.h b/src/bgfx_p.h index f5560c0d..575e0cb2 100644 --- a/src/bgfx_p.h +++ b/src/bgfx_p.h @@ -485,11 +485,9 @@ namespace bgfx InvProj, ViewProj, InvViewProj, - ViewProjX, Model, ModelView, ModelViewProj, - ModelViewProjX, AlphaRef, Count }; @@ -1331,7 +1329,6 @@ namespace bgfx Rect m_scissor[BGFX_CONFIG_MAX_VIEWS]; Matrix4 m_view[BGFX_CONFIG_MAX_VIEWS]; Matrix4 m_proj[BGFX_CONFIG_MAX_VIEWS]; - uint8_t m_other[BGFX_CONFIG_MAX_VIEWS]; uint64_t m_sortKeys[BGFX_CONFIG_MAX_DRAW_CALLS]; uint16_t m_sortValues[BGFX_CONFIG_MAX_DRAW_CALLS]; @@ -2546,17 +2543,8 @@ namespace bgfx } } - BGFX_API_FUNC(void setViewTransform(uint8_t _id, const void* _view, const void* _proj, uint8_t _other) ) + BGFX_API_FUNC(void setViewTransform(uint8_t _id, const void* _view, const void* _proj) ) { - if (BGFX_CONFIG_MAX_VIEWS > _other) - { - m_other[_id] = _other; - } - else - { - m_other[_id] = _id; - } - if (NULL != _view) { memcpy(m_view[_id].un.val, _view, sizeof(Matrix4) ); @@ -2576,14 +2564,14 @@ namespace bgfx } } - BGFX_API_FUNC(void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj, uint8_t _other) ) + BGFX_API_FUNC(void setViewTransformMask(uint32_t _viewMask, const void* _view, const void* _proj) ) { for (uint32_t view = 0, viewMask = _viewMask, ntz = bx::uint32_cnttz(_viewMask); 0 != viewMask; viewMask >>= 1, view += 1, ntz = bx::uint32_cnttz(viewMask) ) { viewMask >>= ntz; view += ntz; - setViewTransform( (uint8_t)view, _view, _proj, _other); + setViewTransform( (uint8_t)view, _view, _proj); } } @@ -2841,7 +2829,6 @@ namespace bgfx Rect m_scissor[BGFX_CONFIG_MAX_VIEWS]; Matrix4 m_view[BGFX_CONFIG_MAX_VIEWS]; Matrix4 m_proj[BGFX_CONFIG_MAX_VIEWS]; - uint8_t m_other[BGFX_CONFIG_MAX_VIEWS]; uint16_t m_seq[BGFX_CONFIG_MAX_VIEWS]; uint16_t m_seqMask[BGFX_CONFIG_MAX_VIEWS]; diff --git a/src/config.h b/src/config.h index 67e12e34..fb81c5d3 100644 --- a/src/config.h +++ b/src/config.h @@ -25,7 +25,7 @@ # ifndef BGFX_CONFIG_RENDERER_DIRECT3D11 # define BGFX_CONFIG_RENDERER_DIRECT3D11 (0 \ - || (BX_PLATFORM_WINDOWS && BX_PLATFORM_WINDOWS >= 0x0602 /*_WIN32_WINNT_WIN8*/) \ + || (BX_PLATFORM_WINDOWS && BX_PLATFORM_WINDOWS >= 0x0601 /*_WIN32_WINNT_WIN7*/) \ ? 1 : 0) # endif // BGFX_CONFIG_RENDERER_DIRECT3D11 diff --git a/src/renderer_d3d11.cpp b/src/renderer_d3d11.cpp index e26f366b..99e37916 100644 --- a/src/renderer_d3d11.cpp +++ b/src/renderer_d3d11.cpp @@ -183,14 +183,6 @@ namespace bgfx }, }; - static const Matrix4 s_bias = - {{{ - 0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.5f, 0.0f, - 0.5f, 0.5f, 0.5f, 1.0f, - }}}; - struct TextureFormatInfo { DXGI_FORMAT m_fmt; @@ -2736,31 +2728,6 @@ namespace bgfx } break; - case PredefinedUniform::ModelViewProjX: - { - const Matrix4& model = _render->m_matrixCache.m_cache[state.m_matrix]; - - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - Matrix4 modelViewProj; - bx::float4x4_mul(&modelViewProj.un.f4x4, &model.un.f4x4, &viewProjBias.un.f4x4); - - setShaderConstant(flags, predefined.m_loc, modelViewProj.un.val, bx::uint32_min(4, predefined.m_count) ); - } - break; - - case PredefinedUniform::ViewProjX: - { - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - setShaderConstant(flags, predefined.m_loc, viewProjBias.un.val, bx::uint32_min(4, predefined.m_count) ); - } - break; - case PredefinedUniform::AlphaRef: { setShaderConstant(flags, predefined.m_loc, &alphaRef, 1); diff --git a/src/renderer_d3d9.cpp b/src/renderer_d3d9.cpp index d3615a19..f42a628d 100644 --- a/src/renderer_d3d9.cpp +++ b/src/renderer_d3d9.cpp @@ -239,14 +239,6 @@ namespace bgfx { D3DFMT_RAWZ, D3DUSAGE_DEPTHSTENCIL, D3DRTYPE_SURFACE, false }, }; - static const Matrix4 s_bias = - {{{ - 0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.5f, 0.0f, - 0.5f, 0.5f, 0.5f, 1.0f, - }}}; - static const GUID IID_IDirect3D9 = { 0x81bdcbca, 0x64d4, 0x426d, { 0xae, 0x8d, 0xad, 0x1, 0x47, 0xf4, 0x27, 0x5c } }; static const GUID IID_IDirect3DDevice9Ex = { 0xb18b10ce, 0x2649, 0x405a, { 0x87, 0xf, 0x95, 0xf7, 0x77, 0xd4, 0x31, 0x3a } }; @@ -2948,31 +2940,6 @@ namespace bgfx } break; - case PredefinedUniform::ModelViewProjX: - { - const Matrix4& model = _render->m_matrixCache.m_cache[state.m_matrix]; - - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - Matrix4 modelViewProj; - bx::float4x4_mul(&modelViewProj.un.f4x4, &model.un.f4x4, &viewProjBias.un.f4x4); - - setShaderConstantF(flags, predefined.m_loc, modelViewProj.un.val, bx::uint32_min(4, predefined.m_count) ); - } - break; - - case PredefinedUniform::ViewProjX: - { - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - setShaderConstantF(flags, predefined.m_loc, viewProjBias.un.val, bx::uint32_min(4, predefined.m_count) ); - } - break; - case PredefinedUniform::AlphaRef: { setShaderConstantF(flags, predefined.m_loc, &alphaRef, 1); diff --git a/src/renderer_gl.cpp b/src/renderer_gl.cpp index 8334c882..b8b138f8 100644 --- a/src/renderer_gl.cpp +++ b/src/renderer_gl.cpp @@ -208,14 +208,6 @@ namespace bgfx { GL_STENCIL_INDEX8, GL_DEPTH_STENCIL, GL_UNSIGNED_BYTE, false }, // D0S8 }; - static const Matrix4 s_bias = - {{{ - 0.5f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.5f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.5f, 0.0f, - 0.5f, 0.5f, 0.5f, 1.0f, - }}}; - struct Extension { enum Enum @@ -4122,39 +4114,6 @@ namespace bgfx } break; - case PredefinedUniform::ModelViewProjX: - { - const Matrix4& model = _render->m_matrixCache.m_cache[state.m_matrix]; - - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - Matrix4 modelViewProj; - bx::float4x4_mul(&modelViewProj.un.f4x4, &model.un.f4x4, &viewProjBias.un.f4x4); - - GL_CHECK(glUniformMatrix4fv(predefined.m_loc - , 1 - , GL_FALSE - , modelViewProj.un.val - ) ); - } - break; - - case PredefinedUniform::ViewProjX: - { - uint8_t other = _render->m_other[view]; - Matrix4 viewProjBias; - bx::float4x4_mul(&viewProjBias.un.f4x4, &viewProj[other].un.f4x4, &s_bias.un.f4x4); - - GL_CHECK(glUniformMatrix4fv(predefined.m_loc - , 1 - , GL_FALSE - , viewProjBias.un.val - ) ); - } - break; - case PredefinedUniform::AlphaRef: { GL_CHECK(glUniform1f(predefined.m_loc, alphaRef) );