summaryrefslogtreecommitdiffstats
path: root/tools/render-test/shader-renderer-util.cpp
diff options
context:
space:
mode:
authorSimon Kallweit <64953474+skallweitNV@users.noreply.github.com>2025-04-24 10:23:06 +0200
committerGitHub <noreply@github.com>2025-04-24 08:23:06 +0000
commitae1a5e40880808252c68eb51e44051b32a34d399 (patch)
tree5084b274b2929658bab9bfdf2b96e22c5b440a83 /tools/render-test/shader-renderer-util.cpp
parentb78a8ba006fc9253cd1fd88fb7dd1eacfa749dfa (diff)
update slang-rhi (#6587)
* update slang-rhi submodule * slang-rhi API changes * disable agility sdk * fix texture creation * update formats in tests * Extent3D rename * use 1 mip level for 1D textures for Metal * fix texture upload * update to latest slang-rhi * update slang-rhi * format code * update slang-rhi * do not run texture-intrinsics test on metal * update slang-rhi * deal with failing tests * fix more tests * update slang-rhi --------- Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Simon Kallweit <simon.kallweit@gmail.com>
Diffstat (limited to 'tools/render-test/shader-renderer-util.cpp')
-rw-r--r--tools/render-test/shader-renderer-util.cpp57
1 files changed, 37 insertions, 20 deletions
diff --git a/tools/render-test/shader-renderer-util.cpp b/tools/render-test/shader-renderer-util.cpp
index 73921fef7..5046a1b10 100644
--- a/tools/render-test/shader-renderer-util.cpp
+++ b/tools/render-test/shader-renderer-util.cpp
@@ -14,9 +14,9 @@ inline int calcMipSize(int size, int level)
return size > 0 ? size : 1;
}
-inline Extents calcMipSize(Extents size, int mipLevel)
+inline Extent3D calcMipSize(Extent3D size, int mipLevel)
{
- Extents rs;
+ Extent3D rs;
rs.width = calcMipSize(size.width, mipLevel);
rs.height = calcMipSize(size.height, mipLevel);
rs.depth = calcMipSize(size.depth, mipLevel);
@@ -24,7 +24,7 @@ inline Extents calcMipSize(Extents size, int mipLevel)
}
/// Given the type works out the maximum dimension size
-inline int calcMaxDimension(Extents size, TextureType type)
+inline int calcMaxDimension(Extent3D size, TextureType type)
{
switch (type)
{
@@ -43,7 +43,7 @@ inline int calcMaxDimension(Extents size, TextureType type)
}
/// Given the type, calculates the number of mip maps. 0 on error
-inline int calcNumMipLevels(TextureType type, Extents size)
+inline int calcNumMipLevels(TextureType type, Extent3D size)
{
const int maxDimensionSize = calcMaxDimension(size, type);
return (maxDimensionSize > 0) ? (Math::Log2Floor(maxDimensionSize) + 1) : 0;
@@ -69,14 +69,21 @@ inline int calcNumMipLevels(TextureType type, Extents size)
{
TextureDesc textureDesc = {};
- // Default to R8G8B8A8_UNORM
+ // Default to RGBA8Unorm
const Format format =
- (inputDesc.format == Format::Unknown) ? Format::R8G8B8A8_UNORM : inputDesc.format;
+ (inputDesc.format == Format::Undefined) ? Format::RGBA8Unorm : inputDesc.format;
+
+ const FormatInfo& formatInfo = getFormatInfo(format);
+
+ bool isArray = inputDesc.arrayLength > 1;
textureDesc.sampleCount = inputDesc.sampleCount;
textureDesc.format = format;
- textureDesc.mipLevelCount = texData.m_mipLevels;
- textureDesc.arrayLength = inputDesc.arrayLength > 0 ? inputDesc.arrayLength : 1;
+ textureDesc.mipCount = texData.m_mipLevels;
+ if (isArray)
+ {
+ textureDesc.arrayLength = inputDesc.arrayLength;
+ }
textureDesc.usage = TextureUsage::CopyDestination | TextureUsage::CopySource;
switch (defaultState)
{
@@ -96,7 +103,7 @@ inline int calcNumMipLevels(TextureType type, Extents size)
{
case 1:
{
- textureDesc.type = TextureType::Texture1D;
+ textureDesc.type = isArray ? TextureType::Texture1DArray : TextureType::Texture1D;
textureDesc.size.width = inputDesc.size;
textureDesc.size.height = 1;
textureDesc.size.depth = 1;
@@ -105,7 +112,10 @@ inline int calcNumMipLevels(TextureType type, Extents size)
}
case 2:
{
- textureDesc.type = inputDesc.isCube ? TextureType::TextureCube : TextureType::Texture2D;
+ textureDesc.type =
+ isArray ? (inputDesc.isCube ? TextureType::TextureCubeArray
+ : TextureType::Texture2DArray)
+ : (inputDesc.isCube ? TextureType::TextureCube : TextureType::Texture2D);
textureDesc.size.width = inputDesc.size;
textureDesc.size.height = inputDesc.size;
textureDesc.size.depth = 1;
@@ -121,30 +131,37 @@ inline int calcNumMipLevels(TextureType type, Extents size)
}
}
- if (textureDesc.mipLevelCount == 0)
+ if (textureDesc.mipCount == 0)
+ {
+ textureDesc.mipCount = calcNumMipLevels(textureDesc.type, textureDesc.size);
+ }
+
+ // Metal doesn't support mip maps for 1D textures.
+ if (device->getDeviceType() == DeviceType::Metal &&
+ (textureDesc.type == TextureType::Texture1D ||
+ textureDesc.type == TextureType::Texture1DArray))
{
- textureDesc.mipLevelCount = calcNumMipLevels(textureDesc.type, textureDesc.size);
+ textureDesc.mipCount = 1;
}
List<SubresourceData> initSubresources;
- int arrayLayerCount =
- textureDesc.arrayLength * (textureDesc.type == TextureType::TextureCube ? 6 : 1);
+ int layerCount = textureDesc.getLayerCount();
int subResourceCounter = 0;
- for (int a = 0; a < arrayLayerCount; ++a)
+ for (int a = 0; a < layerCount; ++a)
{
- for (int m = 0; m < textureDesc.mipLevelCount; ++m)
+ for (int m = 0; m < textureDesc.mipCount; ++m)
{
int subResourceIndex = subResourceCounter++;
const int mipWidth = calcMipSize(textureDesc.size.width, m);
const int mipHeight = calcMipSize(textureDesc.size.height, m);
- auto strideY = mipWidth * sizeof(uint32_t);
- auto strideZ = mipHeight * strideY;
+ size_t rowPitch = mipWidth * formatInfo.blockSizeInBytes;
+ size_t slicePitch = mipHeight * rowPitch;
SubresourceData subresourceData;
subresourceData.data = texData.m_slices[subResourceIndex].values;
- subresourceData.strideY = strideY;
- subresourceData.strideZ = strideZ;
+ subresourceData.rowPitch = rowPitch;
+ subresourceData.slicePitch = slicePitch;
initSubresources.add(subresourceData);
}