Skip to content

Commit

Permalink
WGPU: Create cube textures with one layer per face (#108)
Browse files Browse the repository at this point in the history
* WGPU: Create cube textures with one layer per face

This helps to address
shader-slang/slang#4943

* Update src/wgpu/wgpu-texture.cpp

* Update src/wgpu/wgpu-texture.cpp

* Update src/wgpu/wgpu-texture.cpp

---------

Co-authored-by: Simon Kallweit <[email protected]>
  • Loading branch information
aleino-nv and skallweitNV authored Nov 15, 2024
1 parent 1b6b405 commit ed04b02
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/wgpu/wgpu-texture.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,24 @@ Result DeviceImpl::createTexture(const TextureDesc& desc_, const SubresourceData
WGPUTextureDescriptor textureDesc = {};
textureDesc.size.width = desc.size.width;
textureDesc.size.height = desc.size.height;
textureDesc.size.depthOrArrayLayers = desc.size.depth;
if (desc.type == TextureType::Texture3D)
{
textureDesc.size.depthOrArrayLayers = desc.size.depth;
}
else
{
uint32_t arrayLayers = std::max(1, desc.arrayLength);
switch (desc.type)
{
case TextureType::TextureCube:
arrayLayers *= 6U;
break;
case TextureType::Texture1D:
arrayLayers = 1U;
break;
}
textureDesc.size.depthOrArrayLayers = arrayLayers;
}
textureDesc.usage = translateTextureUsage(desc.usage);
if (initData)
{
Expand Down

0 comments on commit ed04b02

Please sign in to comment.