Fixed compute buffer.
This commit is contained in:
parent
19ad953546
commit
47f100d70f
39
src/bgfx_p.h
39
src/bgfx_p.h
@ -2051,23 +2051,18 @@ namespace bgfx
|
|||||||
uint64_t ptr = 0;
|
uint64_t ptr = 0;
|
||||||
if (0 != (_flags & BGFX_BUFFER_COMPUTE_WRITE) )
|
if (0 != (_flags & BGFX_BUFFER_COMPUTE_WRITE) )
|
||||||
{
|
{
|
||||||
ptr = m_gpuDvbAllocator.alloc(size);
|
VertexBufferHandle vertexBufferHandle = { m_vertexBufferHandle.alloc() };
|
||||||
if (ptr == NonLocalAllocator::invalidBlock)
|
if (!isValid(vertexBufferHandle) )
|
||||||
{
|
{
|
||||||
VertexBufferHandle vertexBufferHandle = { m_vertexBufferHandle.alloc() };
|
return handle;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CommandBuffer& cmdbuf = getCommandBuffer(CommandBuffer::CreateDynamicVertexBuffer);
|
||||||
|
cmdbuf.write(vertexBufferHandle);
|
||||||
|
cmdbuf.write(size);
|
||||||
|
cmdbuf.write(_flags);
|
||||||
|
|
||||||
|
ptr = uint64_t(vertexBufferHandle.idx)<<32;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -2096,13 +2091,14 @@ namespace bgfx
|
|||||||
|
|
||||||
handle.idx = m_dynamicVertexBufferHandle.alloc();
|
handle.idx = m_dynamicVertexBufferHandle.alloc();
|
||||||
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx];
|
DynamicVertexBuffer& dvb = m_dynamicVertexBuffers[handle.idx];
|
||||||
dvb.m_handle.idx = uint16_t(ptr>>32);
|
dvb.m_handle.idx = uint16_t(ptr>>32);
|
||||||
dvb.m_offset = uint32_t(ptr);
|
dvb.m_offset = uint32_t(ptr);
|
||||||
dvb.m_size = size;
|
dvb.m_size = size;
|
||||||
dvb.m_startVertex = dvb.m_offset/_decl.m_stride;
|
dvb.m_startVertex = dvb.m_offset/_decl.m_stride;
|
||||||
dvb.m_numVertices = dvb.m_size/_decl.m_stride;
|
dvb.m_numVertices = dvb.m_size/_decl.m_stride;
|
||||||
dvb.m_decl = declHandle;
|
dvb.m_stride = _decl.m_stride;
|
||||||
dvb.m_flags = _flags;
|
dvb.m_decl = declHandle;
|
||||||
|
dvb.m_flags = _flags;
|
||||||
m_declRef.add(dvb.m_handle, declHandle, _decl.m_hash);
|
m_declRef.add(dvb.m_handle, declHandle, _decl.m_hash);
|
||||||
|
|
||||||
return handle;
|
return handle;
|
||||||
@ -2149,7 +2145,7 @@ namespace bgfx
|
|||||||
|
|
||||||
if (0 != (dvb.m_flags & BGFX_BUFFER_COMPUTE_WRITE) )
|
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
|
else
|
||||||
{
|
{
|
||||||
@ -3131,7 +3127,6 @@ namespace bgfx
|
|||||||
NonLocalAllocator m_dynamicIndexBufferAllocator;
|
NonLocalAllocator m_dynamicIndexBufferAllocator;
|
||||||
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS> m_dynamicIndexBufferHandle;
|
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_INDEX_BUFFERS> m_dynamicIndexBufferHandle;
|
||||||
NonLocalAllocator m_cpuDvbAllocator;
|
NonLocalAllocator m_cpuDvbAllocator;
|
||||||
NonLocalAllocator m_gpuDvbAllocator;
|
|
||||||
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS> m_dynamicVertexBufferHandle;
|
bx::HandleAllocT<BGFX_CONFIG_MAX_DYNAMIC_VERTEX_BUFFERS> m_dynamicVertexBufferHandle;
|
||||||
|
|
||||||
bx::HandleAllocT<BGFX_CONFIG_MAX_INDEX_BUFFERS> m_indexBufferHandle;
|
bx::HandleAllocT<BGFX_CONFIG_MAX_INDEX_BUFFERS> m_indexBufferHandle;
|
||||||
|
@ -1303,14 +1303,14 @@ RENDERDOC_IMPORT
|
|||||||
{
|
{
|
||||||
m_deviceCtx->CSSetShader(NULL, NULL, 0);
|
m_deviceCtx->CSSetShader(NULL, NULL, 0);
|
||||||
|
|
||||||
ID3D11UnorderedAccessView* uav[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||||
m_deviceCtx->CSSetUnorderedAccessViews(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, uav, NULL);
|
m_deviceCtx->CSSetUnorderedAccessViews(0, BX_COUNTOF(uav), uav, NULL);
|
||||||
|
|
||||||
ID3D11ShaderResourceView* srv[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
ID3D11ShaderResourceView* srv[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||||
m_deviceCtx->CSSetShaderResources(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, srv);
|
m_deviceCtx->CSSetShaderResources(0, BX_COUNTOF(srv), srv);
|
||||||
|
|
||||||
ID3D11SamplerState* samplers[BGFX_CONFIG_MAX_TEXTURE_SAMPLERS] = {};
|
ID3D11SamplerState* samplers[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||||
m_deviceCtx->CSSetSamplers(0, BGFX_CONFIG_MAX_TEXTURE_SAMPLERS, samplers);
|
m_deviceCtx->CSSetSamplers(0, BX_COUNTOF(samplers), samplers);
|
||||||
}
|
}
|
||||||
|
|
||||||
void updateMsaa()
|
void updateMsaa()
|
||||||
@ -1344,10 +1344,10 @@ RENDERDOC_IMPORT
|
|||||||
|| getBufferHeight() != _resolution.m_height
|
|| getBufferHeight() != _resolution.m_height
|
||||||
|| m_flags != flags)
|
|| m_flags != flags)
|
||||||
{
|
{
|
||||||
bool resize = (m_flags&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK);
|
bool resize = true
|
||||||
#if BX_PLATFORM_WINRT
|
&& !BX_ENABLED(BX_PLATFORM_WINRT) // can't use ResizeBuffers on Windows Phone
|
||||||
resize = false; // can't use ResizeBuffers on Windows Phone
|
&& (m_flags&BGFX_RESET_MSAA_MASK) == (flags&BGFX_RESET_MSAA_MASK)
|
||||||
#endif
|
;
|
||||||
m_flags = flags;
|
m_flags = flags;
|
||||||
|
|
||||||
m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
|
m_textVideoMem.resize(false, _resolution.m_width, _resolution.m_height);
|
||||||
@ -1390,7 +1390,7 @@ RENDERDOC_IMPORT
|
|||||||
, &m_scd
|
, &m_scd
|
||||||
, &m_swapChain
|
, &m_swapChain
|
||||||
);
|
);
|
||||||
#endif
|
#endif // BX_PLATFORM_WINRT
|
||||||
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain.");
|
BGFX_FATAL(SUCCEEDED(hr), bgfx::Fatal::UnableToInitialize, "Failed to create swap chain.");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3346,7 +3346,7 @@ RENDERDOC_IMPORT
|
|||||||
BX_UNUSED(programChanged);
|
BX_UNUSED(programChanged);
|
||||||
ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
ID3D11UnorderedAccessView* uav[BGFX_MAX_COMPUTE_BINDINGS] = {};
|
||||||
ID3D11ShaderResourceView* srv[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)
|
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->CSSetUnorderedAccessViews(0, BX_COUNTOF(uav), uav, NULL);
|
||||||
deviceCtx->CSSetShaderResources(0, BGFX_MAX_COMPUTE_BINDINGS, srv);
|
deviceCtx->CSSetShaderResources(0, BX_COUNTOF(srv), srv);
|
||||||
deviceCtx->CSSetSamplers(0, BGFX_MAX_COMPUTE_BINDINGS, sampler);
|
deviceCtx->CSSetSamplers(0, BX_COUNTOF(sampler), sampler);
|
||||||
|
|
||||||
deviceCtx->Dispatch(compute.m_numX, compute.m_numY, compute.m_numZ);
|
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)
|
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]
|
, s_primName[ii]
|
||||||
, statsNumPrimsRendered[ii]
|
, statsNumPrimsRendered[ii]
|
||||||
, statsNumInstances[ii]
|
, statsNumInstances[ii]
|
||||||
|
@ -3505,7 +3505,7 @@ namespace bgfx
|
|||||||
);
|
);
|
||||||
for (uint32_t ii = 0; ii < BX_COUNTOF(s_primName); ++ii)
|
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]
|
, s_primName[ii]
|
||||||
, statsNumPrimsRendered[ii]
|
, statsNumPrimsRendered[ii]
|
||||||
, statsNumInstances[ii]
|
, statsNumInstances[ii]
|
||||||
|
Loading…
Reference in New Issue
Block a user