WebGPU: Add texture format to shaderc (bin version 10) + streamline storage Images in shaders (#2482)

* WebGPU: Add texture format (shaderc bin version 10)

* WebGPU: Simplify storage images + Fix format decorations

* Shaderc: Cleanup Texture name assumption in textures
This commit is contained in:
Hugo Amnov
2021-04-21 05:18:49 +02:00
committed by GitHub
parent e8d4b3dcce
commit 24be4a38d0
17 changed files with 336 additions and 257 deletions

View File

@@ -1379,6 +1379,13 @@ namespace bgfx { namespace webgpu
wgpu::BindGroupEntry& entry = b.m_entries[b.numEntries++];
entry.binding = bindInfo.m_binding;
entry.textureView = texture.getTextureMipLevel(bind.m_mip);
if (Access::Read == bind.m_access)
{
wgpu::BindGroupEntry& samplerEntry = b.m_entries[b.numEntries++];
samplerEntry.binding = bindInfo.m_binding + 16;
samplerEntry.sampler = texture.m_sampler;
}
}
break;
@@ -2515,7 +2522,7 @@ namespace bgfx { namespace webgpu
const bool fragment = isShaderType(magic, 'F');
uint8_t fragmentBit = fragment ? kUniformFragmentBit : 0;
BX_ASSERT(!isShaderVerLess(magic, 7), "WebGPU backend supports only shader binary version >= 7");
BX_ASSERT(!isShaderVerLess(magic, 10), "WebGPU backend supports only shader binary version >= 10");
if (0 < count)
{
@@ -2546,6 +2553,9 @@ namespace bgfx { namespace webgpu
uint8_t texDimension;
bx::read(&reader, texDimension);
uint16_t texFormat = 0;
bx::read(&reader, texFormat);
const char* kind = "invalid";
PredefinedUniform::Enum predefined = nameToPredefinedUniformEnum(name);
@@ -2584,6 +2594,8 @@ namespace bgfx { namespace webgpu
m_buffers[m_numBuffers].storageTexture.access = readonly
? wgpu::StorageTextureAccess::ReadOnly
: wgpu::StorageTextureAccess::WriteOnly;
m_buffers[m_numBuffers].storageTexture.format = s_textureFormat[texFormat].m_fmt;
}
m_numBuffers++;