mirror of
https://github.com/scratchfoundation/bgfx.git
synced 2024-11-28 10:35:43 -05:00
Fixed compute buffer.
This commit is contained in:
parent
19ad953546
commit
47f100d70f
3 changed files with 34 additions and 39 deletions
39
src/bgfx_p.h
39
src/bgfx_p.h
|
@ -2051,23 +2051,18 @@ namespace bgfx
|
|||
uint64_t ptr = 0;
|
||||
if (0 != (_flags & BGFX_BUFFER_COMPUTE_WRITE) )
|
||||
{
|
||||
ptr = m_gpuDvbAllocator.alloc(size);
|
||||
if (ptr == NonLocalAllocator::invalidBlock)
|
||||
VertexBufferHandle vertexBufferHandle = { m_vertexBufferHandle.alloc() };
|
||||
if (!isValid(vertexBufferHandle) )
|
||||
{
|
||||
VertexBufferHandle vertexBufferHandle = { m_vertexBufferHandle.alloc() };
|
||||
if (!isValid(vertexBufferHandle) )
|
||||
{
|
||||
return handle;
|
||||
}
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
|
||||
cmdbuf.write(vertexBufferHandle);
|
||||
cmdbuf.write(BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE);
|
||||
cmdbuf.write(_flags);
|
||||
|
||||
m_gpuDvbAllocator.add(uint64_t(vertexBufferHandle.idx)<<32, BGFX_CONFIG_DYNAMIC_VERTEX_BUFFER_SIZE);
|
||||
ptr = m_gpuDvbAllocator.alloc(size);
|
||||
return handle;
|
||||
}
|
||||
|
||||
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
|
||||
cmdbuf.write(vertexBufferHandle);
|
||||
cmdbuf.write(size);
|
||||
cmdbuf.write(_flags);
|
||||
|
||||
ptr = uint64_t(vertexBufferHandle.idx)<<32;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -2096,13 +2091,14 @@ namespace bgfx
|
|||
|
||||
handle.idx = m_dynamicVertexBufferHandle.alloc();
|
||||
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx];
|
||||
dvb.m_handle.idx = uint16_t(ptr>>32);
|
||||
dvb.m_offset = uint32_t(ptr);
|
||||
dvb.m_size = size;
|
||||
dvb.m_handle.idx = uint16_t(ptr>>32);
|
||||
dvb.m_offset = uint32_t(ptr);
|
||||
dvb.m_size = size;
|
||||
dvb.m_startVertex = dvb.m_offset/_decl.m_stride;
|
||||
dvb.m_numVertices = dvb.m_size/_decl.m_stride;
|
||||
dvb.m_decl = declHandle;
|
||||
dvb.m_flags = _flags;
|
||||
dvb.m_stride = _decl.m_stride;
|
||||
dvb.m_decl = declHandle;
|
||||
dvb.m_flags = _flags;
|
||||
m_declRef.add(dvb.m_handle, declHandle, _decl.m_hash);
|
||||
|
||||
return handle;
|
||||
|
@ -2149,7 +2145,7 @@ namespace bgfx
|
|||
|
||||
if (0 != (dvb.m_flags & BGFX_BUFFER_COMPUTE_WRITE) )
|
||||
{
|
||||
m_gpuDvbAllocator.free(uint64_t(dvb.m_handle.idx)<<32 | dvb.m_offset);
|
||||
destroyVertexBuffer(dvb.m_handle);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -3131,7 +3127,6 @@ namespace bgfx
|
|||
NonLocalAllocator m_dynamicIndexBufferAllocator;
|
||||
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS> m_dynamicIndexBufferHandle;
|
||||
NonLocalAllocator m_cpuDvbAllocator;
|
||||
NonLocalAllocator m_gpuDvbAllocator;
|
||||
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS> m_dynamicVertexBufferHandle;
|
||||
|
||||
bx::HandleAllocT<BGFX_CONFIG_MAX_INDEX_BUFFERS> m_indexBufferHandle;
|
||||
|
|
|
@ -1303,14 +1303,14 @@ RENDERDOC_IMPORT
|
|||
{
|
||||
m_deviceCtx->CSSetShader(NULL, NULL, 0);
|
||||
|
||||
ID3D11UnorderedAccessView* uav[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
||||
m_deviceCtx->CSSetUnorderedAccessViews(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, uav, NULL);
|
||||
ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
m_deviceCtx->CSSetUnorderedAccessViews(0, BX_COUNTOF(uav), uav, NULL);
|
||||
|
||||
ID3D11ShaderResourceView* srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
||||
m_deviceCtx->CSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, srv);
|
||||
ID3D11ShaderResourceView* srv[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
m_deviceCtx->CSSetShaderResources(0, BX_COUNTOF(srv), srv);
|
||||
|
||||
ID3D11SamplerState* samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
||||
m_deviceCtx->CSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, samplers);
|
||||
ID3D11SamplerState* samplers[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
m_deviceCtx->CSSetSamplers(0, BX_COUNTOF(samplers), samplers);
|
||||
}
|
||||
|
||||
void updateMsaa()
|
||||
|
@ -1344,10 +1344,10 @@ RENDERDOC_IMPORT
|
|||
|| getBufferHeight() != _resolution.m_height
|
||||
|| m_flags != flags)
|
||||
{
|
||||
bool resize = (m_flags&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK);
|
||||
#if BX_PLATFORM_WINRT
|
||||
resize = false; // can't use ResizeBuffers on Windows Phone
|
||||
#endif
|
||||
bool resize = true
|
||||
&& !BX_ENABLED(BX_PLATFORM_WINRT) // can't use ResizeBuffers on Windows Phone
|
||||
&& (m_flags&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK)
|
||||
;
|
||||
m_flags = flags;
|
||||
|
||||
m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
|
||||
|
@ -1390,7 +1390,7 @@ RENDERDOC_IMPORT
|
|||
, &m_scd
|
||||
, &m_swapChain
|
||||
);
|
||||
#endif
|
||||
#endif // BX_PLATFORM_WINRT
|
||||
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain.");
|
||||
}
|
||||
|
||||
|
@ -3346,7 +3346,7 @@ RENDERDOC_IMPORT
|
|||
BX_UNUSED(programChanged);
|
||||
ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
ID3D11ShaderResourceView* srv[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
ID3D11SamplerState* sampler[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
||||
ID3D11SamplerState* sampler[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||
|
||||
for (uint32_t ii = 0; ii < BGFX_MAX_COMPUTE_BINDINGS; ++ii)
|
||||
{
|
||||
|
@ -3387,9 +3387,9 @@ RENDERDOC_IMPORT
|
|||
}
|
||||
}
|
||||
|
||||
deviceCtx->CSSetUnorderedAccessViews(0, BGFX_MAX_COMPUTE_BINDINGS, uav, NULL);
|
||||
deviceCtx->CSSetShaderResources(0, BGFX_MAX_COMPUTE_BINDINGS, srv);
|
||||
deviceCtx->CSSetSamplers(0, BGFX_MAX_COMPUTE_BINDINGS, sampler);
|
||||
deviceCtx->CSSetUnorderedAccessViews(0, BX_COUNTOF(uav), uav, NULL);
|
||||
deviceCtx->CSSetShaderResources(0, BX_COUNTOF(srv), srv);
|
||||
deviceCtx->CSSetSamplers(0, BX_COUNTOF(sampler), sampler);
|
||||
|
||||
deviceCtx->Dispatch(compute.m_numX, compute.m_numY, compute.m_numZ);
|
||||
|
||||
|
@ -3957,7 +3957,7 @@ RENDERDOC_IMPORT
|
|||
);
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
|
||||
{
|
||||
tvm.printf(10, pos++, 0x8e, " %8s: %7d (#inst: %5d), submitted: %7d"
|
||||
tvm.printf(10, pos++, 0x8e, " %9s: %7d (#inst: %5d), submitted: %7d"
|
||||
, s_primName[ii]
|
||||
, statsNumPrimsRendered[ii]
|
||||
, statsNumInstances[ii]
|
||||
|
|
|
@ -3505,7 +3505,7 @@ namespace bgfx
|
|||
);
|
||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
|
||||
{
|
||||
tvm.printf(10, pos++, 0x8e, " %8s: %7d (#inst: %5d), submitted: %7d"
|
||||
tvm.printf(10, pos++, 0x8e, " %9s: %7d (#inst: %5d), submitted: %7d"
|
||||
, s_primName[ii]
|
||||
, statsNumPrimsRendered[ii]
|
||||
, statsNumInstances[ii]
|
||||
|
|
Loading…
Reference in a new issue