mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2025-02-17 20:31:57 -05:00
Added compute dispatch flags.
This commit is contained in:
parent
9d83a5307c
commit
1be040f2ab
6 changed files with 49 additions and 31 deletions
|
@ -1364,7 +1364,7 @@ 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);
|
||||
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);
|
||||
|
||||
/**
|
||||
* Discard all previously set state for draw call.
|
||||
|
|
|
@ -1257,7 +1257,7 @@ namespace bgfx
|
|||
void setImage(uint8_t _stage, UniformHandle _sampler, FrameBufferHandle _handle, uint8_t _attachment, TextureFormat::Enum _format, Access::Enum _access);
|
||||
|
||||
/// Dispatch compute.
|
||||
void dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX = 1, uint16_t _numY = 1, uint16_t _numZ = 1);
|
||||
void dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX = 1, uint16_t _numY = 1, uint16_t _numZ = 1, uint8_t _flags = BGFX_SUBMIT_EYE_FIRST);
|
||||
|
||||
/// Discard all previously set state for draw or compute call.
|
||||
void discard();
|
||||
|
|
|
@ -293,4 +293,10 @@
|
|||
#define BGFX_VIEW_NONE UINT8_C(0x00)
|
||||
#define BGFX_VIEW_STEREO UINT8_C(0x01)
|
||||
|
||||
///
|
||||
#define BGFX_SUBMIT_EYE_LEFT UINT8_C(0x01)
|
||||
#define BGFX_SUBMIT_EYE_RIGHT UINT8_C(0x02)
|
||||
#define BGFX_SUBMIT_EYE_MASK UINT8_C(0x03)
|
||||
#define BGFX_SUBMIT_EYE_FIRST BGFX_SUBMIT_EYE_LEFT
|
||||
|
||||
#endif // BGFX_DEFINES_H_HEADER_GUARD
|
||||
|
|
14
src/bgfx.cpp
14
src/bgfx.cpp
|
@ -734,7 +734,7 @@ namespace bgfx
|
|||
return m_num;
|
||||
}
|
||||
|
||||
uint32_t Frame::dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ)
|
||||
uint32_t Frame::dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags)
|
||||
{
|
||||
if (m_discard)
|
||||
{
|
||||
|
@ -752,9 +752,11 @@ namespace bgfx
|
|||
|
||||
m_compute.m_matrix = m_draw.m_matrix;
|
||||
m_compute.m_num = m_draw.m_num;
|
||||
m_compute.m_numX = bx::uint16_max(_numX, 1);
|
||||
m_compute.m_numY = bx::uint16_max(_numY, 1);
|
||||
m_compute.m_numZ = bx::uint16_max(_numZ, 1);
|
||||
m_compute.m_numX = bx::uint16_max(_numX, 1);
|
||||
m_compute.m_numY = bx::uint16_max(_numY, 1);
|
||||
m_compute.m_numZ = bx::uint16_max(_numZ, 1);
|
||||
m_compute.m_submitFlags = _flags;
|
||||
|
||||
m_key.m_program = _handle.idx;
|
||||
if (invalidHandle != m_key.m_program)
|
||||
{
|
||||
|
@ -2782,10 +2784,10 @@ again:
|
|||
s_ctx->setImage(_stage, _sampler, _handle, _attachment, _format, _access);
|
||||
}
|
||||
|
||||
void dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ)
|
||||
void dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags)
|
||||
{
|
||||
BGFX_CHECK_MAIN_THREAD();
|
||||
s_ctx->dispatch(_id, _handle, _numX, _numY, _numZ);
|
||||
s_ctx->dispatch(_id, _handle, _numX, _numY, _numZ, _flags);
|
||||
}
|
||||
|
||||
void discard()
|
||||
|
|
50
src/bgfx_p.h
50
src/bgfx_p.h
|
@ -1035,24 +1035,25 @@ namespace bgfx
|
|||
{
|
||||
void clear()
|
||||
{
|
||||
m_constBegin = 0;
|
||||
m_constEnd = 0;
|
||||
m_flags = BGFX_STATE_DEFAULT;
|
||||
m_stencil = packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT);
|
||||
m_rgba = 0;
|
||||
m_matrix = 0;
|
||||
m_startIndex = 0;
|
||||
m_numIndices = UINT32_MAX;
|
||||
m_constBegin = 0;
|
||||
m_constEnd = 0;
|
||||
m_flags = BGFX_STATE_DEFAULT;
|
||||
m_stencil = packStencil(BGFX_STENCIL_DEFAULT, BGFX_STENCIL_DEFAULT);
|
||||
m_rgba = 0;
|
||||
m_matrix = 0;
|
||||
m_startIndex = 0;
|
||||
m_numIndices = UINT32_MAX;
|
||||
m_startVertex = 0;
|
||||
m_numVertices = UINT32_MAX;
|
||||
m_instanceDataOffset = 0;
|
||||
m_instanceDataStride = 0;
|
||||
m_numInstances = 1;
|
||||
m_num = 1;
|
||||
m_numInstances = 1;
|
||||
m_num = 1;
|
||||
m_flags = BGFX_SUBMIT_EYE_FIRST;
|
||||
m_scissor = UINT16_MAX;
|
||||
m_vertexBuffer.idx = invalidHandle;
|
||||
m_vertexDecl.idx = invalidHandle;
|
||||
m_indexBuffer.idx = invalidHandle;
|
||||
m_vertexBuffer.idx = invalidHandle;
|
||||
m_vertexDecl.idx = invalidHandle;
|
||||
m_indexBuffer.idx = invalidHandle;
|
||||
m_instanceDataBuffer.idx = invalidHandle;
|
||||
|
||||
for (uint32_t ii = 0; ii < BGFX_CONFIG_MAX_TEXTURE_SAMPLERS; ++ii)
|
||||
|
@ -1077,6 +1078,7 @@ namespace bgfx
|
|||
uint16_t m_numInstances;
|
||||
uint16_t m_num;
|
||||
uint16_t m_scissor;
|
||||
uint8_t m_submitFlags;
|
||||
|
||||
VertexBufferHandle m_vertexBuffer;
|
||||
VertexDeclHandle m_vertexDecl;
|
||||
|
@ -1106,13 +1108,14 @@ namespace bgfx
|
|||
{
|
||||
void clear()
|
||||
{
|
||||
m_constBegin = 0;
|
||||
m_constEnd = 0;
|
||||
m_matrix = 0;
|
||||
m_numX = 0;
|
||||
m_numY = 0;
|
||||
m_numZ = 0;
|
||||
m_num = 0;
|
||||
m_constBegin = 0;
|
||||
m_constEnd = 0;
|
||||
m_matrix = 0;
|
||||
m_numX = 0;
|
||||
m_numY = 0;
|
||||
m_numZ = 0;
|
||||
m_num = 0;
|
||||
m_submitFlags = BGFX_SUBMIT_EYE_FIRST;
|
||||
|
||||
for (uint32_t ii = 0; ii < BGFX_MAX_COMPUTE_BINDINGS; ++ii)
|
||||
{
|
||||
|
@ -1128,6 +1131,7 @@ namespace bgfx
|
|||
uint16_t m_numY;
|
||||
uint16_t m_numZ;
|
||||
uint16_t m_num;
|
||||
uint8_t m_submitFlags;
|
||||
|
||||
ComputeBinding m_bind[BGFX_MAX_COMPUTE_BINDINGS];
|
||||
};
|
||||
|
@ -1419,7 +1423,7 @@ namespace bgfx
|
|||
}
|
||||
|
||||
uint32_t submit(uint8_t _id, int32_t _depth);
|
||||
uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _ngx, uint16_t _ngy, uint16_t _ngz);
|
||||
uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _ngx, uint16_t _ngy, uint16_t _ngz, uint8_t _flags);
|
||||
void sort();
|
||||
|
||||
bool checkAvailTransientIndexBuffer(uint32_t _num)
|
||||
|
@ -3047,9 +3051,9 @@ namespace bgfx
|
|||
setImage(_stage, _sampler, textureHandle, 0, _format, _access);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ) )
|
||||
BGFX_API_FUNC(uint32_t dispatch(uint8_t _id, ProgramHandle _handle, uint16_t _numX, uint16_t _numY, uint16_t _numZ, uint8_t _flags) )
|
||||
{
|
||||
return m_submit->dispatch(_id, _handle, _numX, _numY, _numZ);
|
||||
return m_submit->dispatch(_id, _handle, _numX, _numY, _numZ, _flags);
|
||||
}
|
||||
|
||||
BGFX_API_FUNC(void discard() )
|
||||
|
|
|
@ -3157,6 +3157,12 @@ namespace bgfx
|
|||
|
||||
const RenderCompute& compute = renderItem.compute;
|
||||
|
||||
if (0 != eye
|
||||
&& BGFX_SUBMIT_EYE_LEFT == (compute.m_submitFlags&BGFX_SUBMIT_EYE_MASK) )
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
bool programChanged = false;
|
||||
bool constantsChanged = compute.m_constBegin < compute.m_constEnd;
|
||||
rendererUpdateUniforms(this, _render->m_constantBuffer, compute.m_constBegin, compute.m_constEnd);
|
||||
|
|
Loading…
Reference in a new issue