Skip to content

Commit

Permalink
WGPU: Supply initial data when creating buffers
Browse files Browse the repository at this point in the history
This helps to address shader-slang/slang#5222
  • Loading branch information
aleino-nv committed Nov 1, 2024
1 parent 9d292cb commit db0a1e8
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/wgpu/wgpu-shader-object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,8 @@ Result ShaderObjectImpl::_ensureOrdinaryDataBufferCreatedIfNeeded(
bufferDesc.defaultState = ResourceState::ConstantBuffer;
bufferDesc.memoryType = MemoryType::DeviceLocal;
ComPtr<IBuffer> buffer;
SLANG_RETURN_ON_FAIL(encoder->m_device->createBuffer(bufferDesc, nullptr, buffer.writeRef()));
void * initData = m_constantBufferData.empty() ? nullptr : m_constantBufferData.data();
SLANG_RETURN_ON_FAIL(encoder->m_device->createBuffer(bufferDesc, initData, buffer.writeRef()));
m_constantBuffer = checked_cast<BufferImpl*>(buffer.get());
}

Expand Down

0 comments on commit db0a1e8

Please sign in to comment.