From 4d6445896e104703a2f5a1ab355e0ca7f8336a71 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E9=A3=8E?= Date: Tue, 1 Sep 2020 23:36:52 +0800 Subject: [PATCH] Add missing VertexLayoutHandle for C APIs (#2249) --- bindings/cs/bgfx.cs | 6 ++++-- bindings/d/funcs.d | 20 ++++++++++++++++---- include/bgfx/c99/bgfx.h | 14 ++++++++++---- makefile | 2 +- scripts/bgfx.idl | 17 +++++++++++++---- src/bgfx.idl.inl | 10 ++++++---- 6 files changed, 50 insertions(+), 19 deletions(-) diff --git a/bindings/cs/bgfx.cs b/bindings/cs/bgfx.cs index c7b8b3bab..01f7044d1 100644 --- a/bindings/cs/bgfx.cs +++ b/bindings/cs/bgfx.cs @@ -4160,9 +4160,10 @@ public static partial class bgfx /// Vertex buffer. /// First vertex to render. /// Number of vertices to render. + /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used. /// [DllImport(DllName, EntryPoint="bgfx_set_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void set_vertex_buffer(byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices); + public static extern unsafe void set_vertex_buffer(byte _stream, VertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle); /// /// Set vertex buffer for draw primitive. @@ -4172,9 +4173,10 @@ public static partial class bgfx /// Dynamic vertex buffer. /// First vertex to render. /// Number of vertices to render. + /// Vertex layout for aliasing vertex buffer. If invalid handle is used, vertex layout used for creation of vertex buffer will be used. /// [DllImport(DllName, EntryPoint="bgfx_set_dynamic_vertex_buffer", CallingConvention = CallingConvention.Cdecl)] - public static extern unsafe void set_dynamic_vertex_buffer(byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices); + public static extern unsafe void set_dynamic_vertex_buffer(byte _stream, DynamicVertexBufferHandle _handle, uint _startVertex, uint _numVertices, VertexLayoutHandle _layoutHandle); /// /// Set vertex buffer for draw primitive. diff --git a/bindings/d/funcs.d b/bindings/d/funcs.d index 6b6fd1292..dc6ae0e74 100644 --- a/bindings/d/funcs.d +++ b/bindings/d/funcs.d @@ -1840,8 +1840,11 @@ version(BindBgfx_Static) * _handle = Vertex buffer. * _startVertex = First vertex to render. * _numVertices = Number of vertices to render. + * _layoutHandle = Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. */ - void bgfx_set_vertex_buffer(byte _stream, bgfx_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices); + void bgfx_set_vertex_buffer(byte _stream, bgfx_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -1850,8 +1853,11 @@ version(BindBgfx_Static) * _handle = Dynamic vertex buffer. * _startVertex = First vertex to render. * _numVertices = Number of vertices to render. + * _layoutHandle = Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. */ - void bgfx_set_dynamic_vertex_buffer(byte _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices); + void bgfx_set_dynamic_vertex_buffer(byte _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -4076,8 +4082,11 @@ else * _handle = Vertex buffer. * _startVertex = First vertex to render. * _numVertices = Number of vertices to render. + * _layoutHandle = Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. */ - alias da_bgfx_set_vertex_buffer = void function(byte _stream, bgfx_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices); + alias da_bgfx_set_vertex_buffer = void function(byte _stream, bgfx_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); da_bgfx_set_vertex_buffer bgfx_set_vertex_buffer; /** @@ -4087,8 +4096,11 @@ else * _handle = Dynamic vertex buffer. * _startVertex = First vertex to render. * _numVertices = Number of vertices to render. + * _layoutHandle = Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. */ - alias da_bgfx_set_dynamic_vertex_buffer = void function(byte _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices); + alias da_bgfx_set_dynamic_vertex_buffer = void function(byte _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint _startVertex, uint _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); da_bgfx_set_dynamic_vertex_buffer bgfx_set_dynamic_vertex_buffer; /** diff --git a/include/bgfx/c99/bgfx.h b/include/bgfx/c99/bgfx.h index 8b379b720..a6137cc1e 100644 --- a/include/bgfx/c99/bgfx.h +++ b/include/bgfx/c99/bgfx.h @@ -3000,9 +3000,12 @@ BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffe * @param[in] _handle Vertex buffer. * @param[in] _startVertex First vertex to render. * @param[in] _numVertices Number of vertices to render. + * @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. * */ -BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices); +BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -3011,9 +3014,12 @@ BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handl * @param[in] _handle Dynamic vertex buffer. * @param[in] _startVertex First vertex to render. * @param[in] _numVertices Number of vertices to render. + * @param[in] _layoutHandle Vertex layout for aliasing vertex buffer. If invalid + * handle is used, vertex layout used for creation + * of vertex buffer will be used. * */ -BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices); +BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); /** * Set vertex buffer for draw primitive. @@ -3624,8 +3630,8 @@ struct bgfx_interface_vtbl void (*set_index_buffer)(bgfx_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); void (*set_dynamic_index_buffer)(bgfx_dynamic_index_buffer_handle_t _handle, uint32_t _firstIndex, uint32_t _numIndices); void (*set_transient_index_buffer)(const bgfx_transient_index_buffer_t* _tib, uint32_t _firstIndex, uint32_t _numIndices); - void (*set_vertex_buffer)(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices); - void (*set_dynamic_vertex_buffer)(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices); + void (*set_vertex_buffer)(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); + void (*set_dynamic_vertex_buffer)(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle); void (*set_transient_vertex_buffer)(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices); void (*set_vertex_count)(uint32_t _numVertices); void (*set_instance_data_buffer)(const bgfx_instance_data_buffer_t* _idb, uint32_t _start, uint32_t _num); diff --git a/makefile b/makefile index ea867936e..ea7d9e768 100644 --- a/makefile +++ b/makefile @@ -59,7 +59,7 @@ projgen: ## Generate project files for all configurations. idl: ## Generate code from IDL. @echo Generating code from IDL. - $(GENIE) idl + cd scripts && ../$(GENIE) idl .build/projects/gmake-android-arm: $(GENIE) --gcc=android-arm gmake diff --git a/scripts/bgfx.idl b/scripts/bgfx.idl index dd65dc30d..efcb0b04b 100644 --- a/scripts/bgfx.idl +++ b/scripts/bgfx.idl @@ -2772,10 +2772,14 @@ func.setVertexBuffer { cpponly } --- Set vertex buffer for draw primitive. func.setVertexBuffer "void" - .stream "uint8_t" --- Vertex stream. - .handle "VertexBufferHandle" --- Vertex buffer. - .startVertex "uint32_t" --- First vertex to render. - .numVertices "uint32_t" --- Number of vertices to render. + .stream "uint8_t" --- Vertex stream. + .handle "VertexBufferHandle" --- Vertex buffer. + .startVertex "uint32_t" --- First vertex to render. + .numVertices "uint32_t" --- Number of vertices to render. + .layoutHandle "VertexLayoutHandle" --- Vertex layout for aliasing vertex buffer. If invalid + --- handle is used, vertex layout used for creation + --- of vertex buffer will be used. + { default = "BGFX_INVALID_HANDLE" } --- Set vertex buffer for draw primitive. func.setVertexBuffer { cpponly } @@ -2790,6 +2794,11 @@ func.setVertexBuffer { cname = "set_dynamic_vertex_buffer" } .handle "DynamicVertexBufferHandle" --- Dynamic vertex buffer. .startVertex "uint32_t" --- First vertex to render. .numVertices "uint32_t" --- Number of vertices to render. + .layoutHandle "VertexLayoutHandle" --- Vertex layout for aliasing vertex buffer. If invalid + --- handle is used, vertex layout used for creation + --- of vertex buffer will be used. + { default = "BGFX_INVALID_HANDLE" } + --- Set vertex buffer for draw primitive. func.setVertexBuffer { cpponly } diff --git a/src/bgfx.idl.inl b/src/bgfx.idl.inl index 965dd67be..a9b358801 100644 --- a/src/bgfx.idl.inl +++ b/src/bgfx.idl.inl @@ -1034,16 +1034,18 @@ BGFX_C_API void bgfx_set_transient_index_buffer(const bgfx_transient_index_buffe bgfx::setIndexBuffer((const bgfx::TransientIndexBuffer*)_tib, _firstIndex, _numIndices); } -BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices) +BGFX_C_API void bgfx_set_vertex_buffer(uint8_t _stream, bgfx_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle) { union { bgfx_vertex_buffer_handle_t c; bgfx::VertexBufferHandle cpp; } handle = { _handle }; - bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp); } -BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices) +BGFX_C_API void bgfx_set_dynamic_vertex_buffer(uint8_t _stream, bgfx_dynamic_vertex_buffer_handle_t _handle, uint32_t _startVertex, uint32_t _numVertices, bgfx_vertex_layout_handle_t _layoutHandle) { union { bgfx_dynamic_vertex_buffer_handle_t c; bgfx::DynamicVertexBufferHandle cpp; } handle = { _handle }; - bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices); + union { bgfx_vertex_layout_handle_t c; bgfx::VertexLayoutHandle cpp; } layoutHandle = { _layoutHandle }; + bgfx::setVertexBuffer(_stream, handle.cpp, _startVertex, _numVertices, layoutHandle.cpp); } BGFX_C_API void bgfx_set_transient_vertex_buffer(uint8_t _stream, const bgfx_transient_vertex_buffer_t* _tvb, uint32_t _startVertex, uint32_t _numVertices)