summaryrefslogtreecommitdiffstats
path: root/tools/render-test
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-12-09 04:48:03 -0800
committerGitHub <noreply@github.com>2024-12-09 20:48:03 +0800
commit09a9d673322ebf4ca2fcb7d48f13a44e015ea33f (patch)
tree8bae8fa5718669dcbff98b8bcb29784483905f34 /tools/render-test
parent051ae8acec0a641bcaf86e7eeff35eff29e8922d (diff)
Allow pointers to existential values. (#5793)
* Fix pointer offset logic and add executable tests. * Fix. * Fix test. * Add existential ptr test. * Allow pointers to existential values. * Fix. * Fix. --------- Co-authored-by: Ellie Hermaszewska <ellieh@nvidia.com>
Diffstat (limited to 'tools/render-test')
-rw-r--r--tools/render-test/render-test-main.cpp32
1 files changed, 30 insertions, 2 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index 2e07a7689..5907be66d 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -76,6 +76,12 @@ struct ShaderOutputPlan
List<Item> items;
};
+// A context for hodling resources allocated for a test.
+struct TestResourceContext
+{
+ List<ComPtr<IResource>> resources;
+};
+
class RenderTestApp
{
public:
@@ -134,6 +140,7 @@ protected:
Options m_options;
ShaderOutputPlan m_outputPlan;
+ TestResourceContext m_resourceContext;
};
struct AssignValsFromLayoutContext
@@ -141,6 +148,7 @@ struct AssignValsFromLayoutContext
IDevice* device;
slang::ISession* slangSession;
ShaderOutputPlan& outputPlan;
+ TestResourceContext& resourceContext;
slang::ProgramLayout* slangReflection;
IAccelerationStructure* accelerationStructure;
@@ -148,11 +156,13 @@ struct AssignValsFromLayoutContext
IDevice* device,
slang::ISession* slangSession,
ShaderOutputPlan& outputPlan,
+ TestResourceContext& resourceContext,
slang::ProgramLayout* slangReflection,
IAccelerationStructure* accelerationStructure)
: device(device)
, slangSession(slangSession)
, outputPlan(outputPlan)
+ , resourceContext(resourceContext)
, slangReflection(slangReflection)
, accelerationStructure(accelerationStructure)
{
@@ -204,6 +214,7 @@ struct AssignValsFromLayoutContext
bufferData.add(0);
ComPtr<IBuffer> bufferResource;
+
SLANG_RETURN_ON_FAIL(ShaderRendererUtil::createBuffer(
srcBuffer,
/*entry.isOutput,*/ bufferSize,
@@ -211,6 +222,16 @@ struct AssignValsFromLayoutContext
device,
bufferResource));
+ if (dstCursor.getTypeLayout()->getType()->getKind() == slang::TypeReflection::Kind::Pointer)
+ {
+ // dstCursor is pointer to an ordinary uniform data field,
+ // we should write bufferResource as a pointer.
+ uint64_t addr = bufferResource->getDeviceAddress();
+ dstCursor.setData(&addr, sizeof(addr));
+ resourceContext.resources.add(ComPtr<IResource>(bufferResource.get()));
+ return SLANG_OK;
+ }
+
ComPtr<IBuffer> counterResource;
const auto explicitCounterCursor = dstCursor.getExplicitCounter();
if (srcBuffer.counter != ~0u)
@@ -488,11 +509,17 @@ SlangResult _assignVarsFromLayout(
IShaderObject* shaderObject,
ShaderInputLayout const& layout,
ShaderOutputPlan& ioOutputPlan,
+ TestResourceContext& ioResourceContext,
slang::ProgramLayout* slangReflection,
IAccelerationStructure* accelerationStructure)
{
- AssignValsFromLayoutContext
- context(device, slangSession, ioOutputPlan, slangReflection, accelerationStructure);
+ AssignValsFromLayoutContext context(
+ device,
+ slangSession,
+ ioOutputPlan,
+ ioResourceContext,
+ slangReflection,
+ accelerationStructure);
ShaderCursor rootCursor = ShaderCursor(shaderObject);
return context.assign(rootCursor, layout.rootVal);
}
@@ -510,6 +537,7 @@ Result RenderTestApp::applyBinding(IShaderObject* rootObject)
rootObject,
m_compilationOutput.layout,
m_outputPlan,
+ m_resourceContext,
slangReflection,
m_topLevelAccelerationStructure);
}