mirror of
https://github.com/bkaradzic/bgfx.git
synced 2026-02-20 22:03:12 +01:00
Exposed topology API.
This commit is contained in:
78
src/bgfx.cpp
78
src/bgfx.cpp
@@ -19,6 +19,7 @@
|
||||
#endif // BGFX_CONFIG_PROFILER_REMOTERY_BUILD_LIB
|
||||
|
||||
#include <bx/crtimpl.h>
|
||||
#include "topology.h"
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
@@ -2376,6 +2377,11 @@ again:
|
||||
flushTextureUpdateBatch(_cmdbuf);
|
||||
}
|
||||
|
||||
uint32_t topologyConvert(TopologyConvert::Enum _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32)
|
||||
{
|
||||
return topologyConvert(_conversion, _dst, _dstSize, _indices, _numIndices, _index32, g_allocator);
|
||||
}
|
||||
|
||||
uint8_t getSupportedRenderers(RendererType::Enum _enum[RendererType::Count])
|
||||
{
|
||||
uint8_t num = 0;
|
||||
@@ -3396,12 +3402,22 @@ again:
|
||||
s_ctx->setUniform(_handle, _value, _num);
|
||||
}
|
||||
|
||||
void setIndexBuffer(IndexBufferHandle _handle)
|
||||
{
|
||||
setIndexBuffer(_handle, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void setIndexBuffer(IndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setIndexBuffer(_handle, _firstIndex, _numIndices);
|
||||
}
|
||||
|
||||
void setIndexBuffer(DynamicIndexBufferHandle _handle)
|
||||
{
|
||||
setIndexBuffer(_handle, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void setIndexBuffer(DynamicIndexBufferHandle _handle, uint32_t _firstIndex, uint32_t _numIndices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
@@ -3432,10 +3448,15 @@ again:
|
||||
s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
|
||||
}
|
||||
|
||||
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _numVertices)
|
||||
void setVertexBuffer(DynamicVertexBufferHandle _handle)
|
||||
{
|
||||
setVertexBuffer(_handle, 0, UINT32_MAX);
|
||||
}
|
||||
|
||||
void setVertexBuffer(DynamicVertexBufferHandle _handle, uint32_t _startVertex, uint32_t _numVertices)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->setVertexBuffer(_handle, _numVertices);
|
||||
s_ctx->setVertexBuffer(_handle, _startVertex, _numVertices);
|
||||
}
|
||||
|
||||
void setVertexBuffer(const TransientVertexBuffer* _tvb)
|
||||
@@ -3630,23 +3651,34 @@ BX_STATIC_ASSERT(FLAGS_MASK_TEST(0
|
||||
|
||||
#undef FLAGS_MASK_TEST
|
||||
|
||||
BX_STATIC_ASSERT(bgfx::Fatal::Count == bgfx::Fatal::Enum(BGFX_FATAL_COUNT) );
|
||||
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(bgfx::RenderFrame::Count == bgfx::RenderFrame::Enum(BGFX_RENDER_FRAME_COUNT) );
|
||||
#define BGFX_C99_ENUM_CHECK(_enum, _c99enumcount) \
|
||||
BX_STATIC_ASSERT(_enum::Count == _enum::Enum(_c99enumcount) )
|
||||
|
||||
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) );
|
||||
BX_STATIC_ASSERT(sizeof(bgfx::Caps) == sizeof(bgfx_caps_t) );
|
||||
BX_STATIC_ASSERT(sizeof(bgfx::PlatformData) == sizeof(bgfx_platform_data_t) );
|
||||
BX_STATIC_ASSERT(sizeof(bgfx::InternalData) == sizeof(bgfx_internal_data_t) );
|
||||
BGFX_C99_ENUM_CHECK(bgfx::Fatal, BGFX_FATAL_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::RendererType, BGFX_RENDERER_TYPE_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::Attrib, BGFX_ATTRIB_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::AttribType, BGFX_ATTRIB_TYPE_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::TextureFormat, BGFX_TEXTURE_FORMAT_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::UniformType, BGFX_UNIFORM_TYPE_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::BackbufferRatio, BGFX_BACKBUFFER_RATIO_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::OcclusionQueryResult, BGFX_OCCLUSION_QUERY_RESULT_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::TopologyConvert, BGFX_TOPOLOGY_CONVERT_COUNT);
|
||||
BGFX_C99_ENUM_CHECK(bgfx::RenderFrame, BGFX_RENDER_FRAME_COUNT);
|
||||
#undef BGFX_C99_ENUM_CHECK
|
||||
|
||||
#define BGFX_C99_STRUCT_SIZE_CHECK(_cppstruct, _c99struct) \
|
||||
BX_STATIC_ASSERT(sizeof(_cppstruct) == sizeof(_c99struct) )
|
||||
|
||||
BGFX_C99_STRUCT_SIZE_CHECK(bgfx::Memory, bgfx_memory_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::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);
|
||||
#undef BGFX_C99_STRUCT_SIZE_CHECK
|
||||
|
||||
namespace bgfx
|
||||
{
|
||||
@@ -3775,6 +3807,11 @@ BGFX_C_API uint16_t bgfx_weld_vertices(uint16_t* _output, const bgfx_vertex_decl
|
||||
return bgfx::weldVertices(_output, decl, _data, _num, _epsilon);
|
||||
}
|
||||
|
||||
uint32_t bgfx_topology_convert(bgfx_topology_convert_t _conversion, void* _dst, uint32_t _dstSize, const void* _indices, uint32_t _numIndices, bool _index32)
|
||||
{
|
||||
return bgfx::topologyConvert(bgfx::TopologyConvert::Enum(_conversion), _dst, _dstSize, _indices, _numIndices, _index32);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_image_swizzle_bgra8(uint32_t _width, uint32_t _height, uint32_t _pitch, const void* _src, void* _dst)
|
||||
{
|
||||
bgfx::imageSwizzleBgra8(_width, _height, _pitch, _src, _dst);
|
||||
@@ -4354,10 +4391,10 @@ BGFX_C_API void bgfx_set_vertex_buffer(bgfx_vertex_buffer_handle_t _handle, uint
|
||||
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)
|
||||
BGFX_C_API void bgfx_set_dynamic_vertex_buffer(bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices)
|
||||
{
|
||||
union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle };
|
||||
bgfx::setVertexBuffer(handle.cpp, _numVertices);
|
||||
bgfx::setVertexBuffer(handle.cpp, _startVertex, _numVertices);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_transient_vertex_buffer(const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)
|
||||
@@ -4547,6 +4584,7 @@ BGFX_C_API bgfx_interface_vtbl_t* bgfx_get_interface(uint32_t _version)
|
||||
BGFX_IMPORT_FUNC(vertex_unpack) \
|
||||
BGFX_IMPORT_FUNC(vertex_convert) \
|
||||
BGFX_IMPORT_FUNC(weld_vertices) \
|
||||
BGFX_IMPORT_FUNC(topology_convert) \
|
||||
BGFX_IMPORT_FUNC(image_swizzle_bgra8) \
|
||||
BGFX_IMPORT_FUNC(image_rgba8_downsample_2x2) \
|
||||
BGFX_IMPORT_FUNC(get_supported_renderers) \
|
||||
|
||||
Reference in New Issue
Block a user