mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-02-17 20:31:57 -05:00
Updated C99 API.
This commit is contained in:
parent
1dce7acb10
commit
088bd06b04
2 changed files with 50 additions and 3 deletions
|
@ -166,6 +166,7 @@ typedef enum bgfx_backbuffer_ratio
|
|||
#define BGFX_HANDLE_T(_name) \
|
||||
typedef struct _name { uint16_t idx; } _name##_t;
|
||||
|
||||
BGFX_HANDLE_T(bgfx_indirect_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_dynamic_index_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_dynamic_vertex_buffer_handle);
|
||||
BGFX_HANDLE_T(bgfx_frame_buffer_handle);
|
||||
|
@ -871,6 +872,16 @@ BGFX_C_API bool bgfx_alloc_transient_buffers(bgfx_transient_vertex_buffer_t* _tv
|
|||
*/
|
||||
BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(uint32_t _num, uint16_t _stride);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle);
|
||||
|
||||
/**
|
||||
* Create shader from memory buffer.
|
||||
*/
|
||||
|
@ -1418,6 +1429,11 @@ BGFX_C_API void bgfx_set_texture_from_frame_buffer(uint8_t _stage, bgfx_uniform_
|
|||
*/
|
||||
BGFX_C_API uint32_t bgfx_submit(uint8_t _id, int32_t _depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
BGFX_C_API uint32_t bgfx_submit_indirect(uint8_t _id, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, int32_t _depth);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
|
@ -1431,7 +1447,12 @@ BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_ha
|
|||
/**
|
||||
* Dispatch compute.
|
||||
*/
|
||||
BGFX_C_API void bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags);
|
||||
BGFX_C_API uint32_t bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags);
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
BGFX_C_API uint32_t bgfx_dispatch_indirect(uint8_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw call.
|
||||
|
|
30
src/bgfx.cpp
30
src/bgfx.cpp
|
@ -3321,6 +3321,19 @@ BGFX_C_API const bgfx_instance_data_buffer_t* bgfx_alloc_instance_data_buffer(ui
|
|||
return (bgfx_instance_data_buffer_t*)bgfx::allocInstanceDataBuffer(_num, _stride);
|
||||
}
|
||||
|
||||
BGFX_C_API bgfx_indirect_buffer_handle_t bgfx_create_indirect_buffer(uint32_t _num)
|
||||
{
|
||||
union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle;
|
||||
handle.cpp = bgfx::createIndirectBuffer(_num);
|
||||
return handle.c;
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_destroy_indirect_buffer(bgfx_indirect_buffer_handle_t _handle)
|
||||
{
|
||||
union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } handle = { _handle };
|
||||
bgfx::destroyIndirectBuffer(handle.cpp);
|
||||
}
|
||||
|
||||
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;
|
||||
|
@ -3629,6 +3642,12 @@ 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_indirect(uint8_t _id, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, int32_t _depth)
|
||||
{
|
||||
union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
|
||||
return bgfx::submit(_id, indirectHandle.cpp, _start, _num, _depth);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_set_image(uint8_t _stage, bgfx_uniform_handle_t _sampler, bgfx_texture_handle_t _handle, uint8_t _mip, bgfx_access_t _access, bgfx_texture_format_t _format)
|
||||
{
|
||||
union { bgfx_uniform_handle_t c; bgfx::UniformHandle cpp; } sampler = { _sampler };
|
||||
|
@ -3643,10 +3662,17 @@ BGFX_C_API void bgfx_set_image_from_frame_buffer(uint8_t _stage, bgfx_uniform_ha
|
|||
bgfx::setImage(_stage, sampler.cpp, handle.cpp, _attachment, bgfx::Access::Enum(_access), bgfx::TextureFormat::Enum(_format) );
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags)
|
||||
BGFX_C_API uint32_t bgfx_dispatch(uint8_t _id, bgfx_program_handle_t _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags)
|
||||
{
|
||||
union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
|
||||
bgfx::dispatch(_id, handle.cpp, _numX, _numY, _numZ, _flags);
|
||||
return bgfx::dispatch(_id, handle.cpp, _numX, _numY, _numZ, _flags);
|
||||
}
|
||||
|
||||
BGFX_C_API uint32_t bgfx_dispatch_indirect(uint8_t _id, bgfx_program_handle_t _handle, bgfx_indirect_buffer_handle_t _indirectHandle, uint16_t _start, uint16_t _num, uint8_t _flags)
|
||||
{
|
||||
union { bgfx_program_handle_t c; bgfx::ProgramHandle cpp; } handle = { _handle };
|
||||
union { bgfx_indirect_buffer_handle_t c; bgfx::IndirectBufferHandle cpp; } indirectHandle = { _indirectHandle };
|
||||
return bgfx::dispatch(_id, handle.cpp, indirectHandle.cpp, _start, _num, _flags);
|
||||
}
|
||||
|
||||
BGFX_C_API void bgfx_discard()
|
||||
|
|
Loading…
Reference in a new issue