summaryrefslogtreecommitdiff
path: root/tools
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
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')
-rw-r--r--tools/render-test/render-test-main.cpp65
-rw-r--r--tools/render-test/shader-input-layout.cpp68
-rw-r--r--tools/render-test/shader-input-layout.h6
-rw-r--r--tools/render-test/shader-renderer-util.cpp57
4 files changed, 107 insertions, 89 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index f6a303d62..45b39db67 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -267,7 +267,7 @@ struct AssignValsFromLayoutContext
InputBufferType::StorageBuffer,
sizeof(uint32_t),
1,
- Format::Unknown,
+ Format::Undefined,
};
SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBuffer(
counterBufferDesc,
@@ -613,13 +613,13 @@ SlangResult RenderTestApp::initialize(
// fixed/known set of attributes.
//
const InputElementDesc inputElements[] = {
- {"A", 0, Format::R32G32B32_FLOAT, offsetof(Vertex, position)},
- {"A", 1, Format::R32G32B32_FLOAT, offsetof(Vertex, color)},
- {"A", 2, Format::R32G32_FLOAT, offsetof(Vertex, uv)},
- {"A", 3, Format::R32G32B32A32_FLOAT, offsetof(Vertex, customData0)},
- {"A", 4, Format::R32G32B32A32_FLOAT, offsetof(Vertex, customData1)},
- {"A", 5, Format::R32G32B32A32_FLOAT, offsetof(Vertex, customData2)},
- {"A", 6, Format::R32G32B32A32_FLOAT, offsetof(Vertex, customData3)},
+ {"A", 0, Format::RGB32Float, offsetof(Vertex, position)},
+ {"A", 1, Format::RGB32Float, offsetof(Vertex, color)},
+ {"A", 2, Format::RG32Float, offsetof(Vertex, uv)},
+ {"A", 3, Format::RGBA32Float, offsetof(Vertex, customData0)},
+ {"A", 4, Format::RGBA32Float, offsetof(Vertex, customData1)},
+ {"A", 5, Format::RGBA32Float, offsetof(Vertex, customData2)},
+ {"A", 6, Format::RGBA32Float, offsetof(Vertex, customData3)},
};
ComPtr<IInputLayout> inputLayout;
@@ -639,13 +639,13 @@ SlangResult RenderTestApp::initialize(
device->createBuffer(vertexBufferDesc, kVertexData, m_vertexBuffer.writeRef()));
ColorTargetDesc colorTarget;
- colorTarget.format = Format::R8G8B8A8_UNORM;
+ colorTarget.format = Format::RGBA8Unorm;
RenderPipelineDesc desc;
desc.program = m_shaderProgram;
desc.inputLayout = inputLayout;
desc.targets = &colorTarget;
desc.targetCount = 1;
- desc.depthStencil.format = Format::D32_FLOAT;
+ desc.depthStencil.format = Format::D32Float;
m_pipeline = device->createRenderPipeline(desc);
}
break;
@@ -654,12 +654,12 @@ SlangResult RenderTestApp::initialize(
case Options::ShaderProgramType::GraphicsTaskMeshCompute:
{
ColorTargetDesc colorTarget;
- colorTarget.format = Format::R8G8B8A8_UNORM;
+ colorTarget.format = Format::RGBA8Unorm;
RenderPipelineDesc desc;
desc.program = m_shaderProgram;
desc.targets = &colorTarget;
desc.targetCount = 1;
- desc.depthStencil.format = Format::D32_FLOAT;
+ desc.depthStencil.format = Format::D32Float;
m_pipeline = device->createRenderPipeline(desc);
}
break;
@@ -721,9 +721,9 @@ void RenderTestApp::_initializeRenderPass()
depthBufferDesc.size.width = gWindowWidth;
depthBufferDesc.size.height = gWindowHeight;
depthBufferDesc.size.depth = 1;
- depthBufferDesc.mipLevelCount = 1;
- depthBufferDesc.format = Format::D32_FLOAT;
- depthBufferDesc.usage = TextureUsage::DepthWrite;
+ depthBufferDesc.mipCount = 1;
+ depthBufferDesc.format = Format::D32Float;
+ depthBufferDesc.usage = TextureUsage::DepthStencil;
depthBufferDesc.defaultState = ResourceState::DepthWrite;
m_depthBuffer = m_device->createTexture(depthBufferDesc, nullptr);
SLANG_ASSERT(m_depthBuffer);
@@ -735,8 +735,8 @@ void RenderTestApp::_initializeRenderPass()
colorBufferDesc.size.width = gWindowWidth;
colorBufferDesc.size.height = gWindowHeight;
colorBufferDesc.size.depth = 1;
- colorBufferDesc.mipLevelCount = 1;
- colorBufferDesc.format = Format::R8G8B8A8_UNORM;
+ colorBufferDesc.mipCount = 1;
+ colorBufferDesc.format = Format::RGBA8Unorm;
colorBufferDesc.usage = TextureUsage::RenderTarget | TextureUsage::CopySource;
colorBufferDesc.defaultState = ResourceState::RenderTarget;
m_colorBuffer = m_device->createTexture(colorBufferDesc, nullptr);
@@ -765,17 +765,17 @@ void RenderTestApp::_initializeAccelerationStructure()
// Build bottom level acceleration structure.
{
- AccelerationStructureBuildInputTriangles triangles = {};
- BufferWithOffset vertexBufferWithOffset = vertexBuffer;
- triangles.vertexBuffers = &vertexBufferWithOffset;
- triangles.vertexBufferCount = 1;
- triangles.vertexFormat = Format::R32G32B32_FLOAT;
- triangles.vertexCount = kVertexCount;
- triangles.vertexStride = sizeof(Vertex);
- triangles.preTransformBuffer = transformBuffer;
- triangles.flags = AccelerationStructureGeometryFlags::Opaque;
+ AccelerationStructureBuildInput buildInput = {};
+ buildInput.type = AccelerationStructureBuildInputType::Triangles;
+ buildInput.triangles.vertexBuffers[0] = vertexBuffer;
+ buildInput.triangles.vertexBufferCount = 1;
+ buildInput.triangles.vertexFormat = Format::RGB32Float;
+ buildInput.triangles.vertexCount = kVertexCount;
+ buildInput.triangles.vertexStride = sizeof(Vertex);
+ buildInput.triangles.preTransformBuffer = transformBuffer;
+ buildInput.triangles.flags = AccelerationStructureGeometryFlags::Opaque;
AccelerationStructureBuildDesc buildDesc = {};
- buildDesc.inputs = &triangles;
+ buildDesc.inputs = &buildInput;
buildDesc.inputCount = 1;
buildDesc.flags = AccelerationStructureBuildFlags::AllowCompaction;
@@ -871,12 +871,13 @@ void RenderTestApp::_initializeAccelerationStructure()
ComPtr<IBuffer> instanceBuffer =
m_device->createBuffer(instanceBufferDesc, nativeInstanceDescs.getBuffer());
- AccelerationStructureBuildInputInstances instances = {};
- instances.instanceBuffer = instanceBuffer;
- instances.instanceCount = 1;
- instances.instanceStride = nativeInstanceDescSize;
+ AccelerationStructureBuildInput buildInput = {};
+ buildInput.type = AccelerationStructureBuildInputType::Instances;
+ buildInput.instances.instanceBuffer = instanceBuffer;
+ buildInput.instances.instanceCount = 1;
+ buildInput.instances.instanceStride = nativeInstanceDescSize;
AccelerationStructureBuildDesc buildDesc = {};
- buildDesc.inputs = &instances;
+ buildDesc.inputs = &buildInput;
buildDesc.inputCount = 1;
// Query buffer size for acceleration structure build.
diff --git a/tools/render-test/shader-input-layout.cpp b/tools/render-test/shader-input-layout.cpp
index 25bfb58cf..ab9ed3c7b 100644
--- a/tools/render-test/shader-input-layout.cpp
+++ b/tools/render-test/shader-input-layout.cpp
@@ -30,7 +30,7 @@ Format _getFormatFromName(const UnownedStringSlice& slice)
return Format(i);
}
}
- return Format::Unknown;
+ return Format::Undefined;
}
struct TypeInfo
@@ -150,7 +150,7 @@ struct ShaderInputLayoutParser
{
val->textureDesc.format = parseFormatOption(parser);
- if (val->textureDesc.format == Format::Unknown)
+ if (val->textureDesc.format == Format::Undefined)
{
return SLANG_FAIL;
}
@@ -1294,14 +1294,14 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
switch (desc.format)
{
- case Format::R8G8B8A8_UNORM:
+ case Format::RGBA8Unorm:
{
generateTextureDataRGB8(output, desc);
break;
}
- case Format::R16_FLOAT:
- case Format::R16G16_FLOAT:
- case Format::R16G16B16A16_FLOAT:
+ case Format::R16Float:
+ case Format::RG16Float:
+ case Format::RGBA16Float:
{
generateTextureDataWithTargetTStorage<uint16_t>(
output,
@@ -1310,7 +1310,7 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoHalf);
break;
}
- case Format::R64_UINT:
+ case Format::R64Uint:
{
generateTextureDataWithTargetTStorage<uint64_t>(
output,
@@ -1319,11 +1319,11 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoUint<uint64_t>);
break;
}
- case Format::R32_FLOAT:
- case Format::R32G32_FLOAT:
- case Format::R32G32B32_FLOAT:
- case Format::R32G32B32A32_FLOAT:
- case Format::D32_FLOAT:
+ case Format::R32Float:
+ case Format::RG32Float:
+ case Format::RGB32Float:
+ case Format::RGBA32Float:
+ case Format::D32Float:
{
generateTextureDataWithTargetTStorage<float>(
output,
@@ -1332,10 +1332,10 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoFloat);
break;
}
- case Format::R32_UINT:
- case Format::R32G32_UINT:
- case Format::R32G32B32_UINT:
- case Format::R32G32B32A32_UINT:
+ case Format::R32Uint:
+ case Format::RG32Uint:
+ case Format::RGB32Uint:
+ case Format::RGBA32Uint:
{
generateTextureDataWithTargetTStorage<uint32_t>(
output,
@@ -1344,9 +1344,9 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoUint<uint32_t>);
break;
}
- case Format::R16_UINT:
- case Format::R16G16_UINT:
- case Format::R16G16B16A16_UINT:
+ case Format::R16Uint:
+ case Format::RG16Uint:
+ case Format::RGBA16Uint:
{
generateTextureDataWithTargetTStorage<uint16_t>(
output,
@@ -1355,9 +1355,9 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoUint<uint16_t>);
break;
}
- case Format::R8_UINT:
- case Format::R8G8_UINT:
- case Format::R8G8B8A8_UINT:
+ case Format::R8Uint:
+ case Format::RG8Uint:
+ case Format::RGBA8Uint:
{
generateTextureDataWithTargetTStorage<uint8_t>(
output,
@@ -1366,7 +1366,7 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoUint<uint8_t>);
break;
}
- case Format::R64_SINT:
+ case Format::R64Sint:
{
generateTextureDataWithTargetTStorage<int64_t>(
output,
@@ -1375,10 +1375,10 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoInt<int64_t>);
break;
}
- case Format::R32_SINT:
- case Format::R32G32_SINT:
- case Format::R32G32B32_SINT:
- case Format::R32G32B32A32_SINT:
+ case Format::R32Sint:
+ case Format::RG32Sint:
+ case Format::RGB32Sint:
+ case Format::RGBA32Sint:
{
generateTextureDataWithTargetTStorage<int32_t>(
output,
@@ -1387,9 +1387,9 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoInt<int32_t>);
break;
}
- case Format::R16_SINT:
- case Format::R16G16_SINT:
- case Format::R16G16B16A16_SINT:
+ case Format::R16Sint:
+ case Format::RG16Sint:
+ case Format::RGBA16Sint:
{
generateTextureDataWithTargetTStorage<int16_t>(
output,
@@ -1398,9 +1398,9 @@ void generateTextureData(TextureData& output, const InputTextureDesc& desc)
loadDataIntoInt<int16_t>);
break;
}
- case Format::R8_SINT:
- case Format::R8G8_SINT:
- case Format::R8G8B8A8_SINT:
+ case Format::R8Sint:
+ case Format::RG8Sint:
+ case Format::RGBA8Sint:
{
generateTextureDataWithTargetTStorage<int8_t>(
output,
@@ -1440,7 +1440,7 @@ void generateTextureDataRGB8(TextureData& output, const InputTextureDesc& inputD
if (arrLen == 0)
arrLen = 1;
- output.init(Format::R8G8B8A8_UNORM);
+ output.init(Format::RGBA8Unorm);
enum class SimpleScalarType
{
diff --git a/tools/render-test/shader-input-layout.h b/tools/render-test/shader-input-layout.h
index c7a8a6918..e0a2be886 100644
--- a/tools/render-test/shader-input-layout.h
+++ b/tools/render-test/shader-input-layout.h
@@ -55,7 +55,7 @@ struct InputTextureDesc
int mipMapCount = 0; ///< 0 means the maximum number of mips will be bound
InputTextureSampleCount sampleCount = InputTextureSampleCount::One;
- Format format = Format::R8G8B8A8_UNORM;
+ Format format = Format::RGBA8Unorm;
InputTextureContent content = InputTextureContent::One;
};
@@ -72,7 +72,7 @@ struct InputBufferDesc
InputBufferType type = InputBufferType::StorageBuffer;
int stride = 0; // stride == 0 indicates an unstructured buffer.
int elementCount = 1;
- Format format = Format::Unknown;
+ Format format = Format::Undefined;
// For RWStructuredBuffer, AppendStructuredBuffer, ConsumeStructuredBuffer
// the default value of 0xffffffff indicates that a counter buffer should
// not be assigned
@@ -149,7 +149,7 @@ struct TextureData
m_slices.clear();
}
- rhi::Format m_format = rhi::Format::Unknown;
+ rhi::Format m_format = rhi::Format::Undefined;
uint8_t m_formatSize = 0;
Slang::List<Slice> m_slices;
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);
}