summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnders Leino <aleino@nvidia.com>2025-02-19 09:55:16 +0200
committerGitHub <noreply@github.com>2025-02-18 23:55:16 -0800
commite9a63b2b3822bbc533130ead0ab8ee03b4a4250a (patch)
tree40a477a551c3178d5557b50f06dd2aeae5d2d03c
parent5ceef13e2336dfa1c4de8fdb3a273d81add0a7ca (diff)
Cleanups for render-api (#6360)
* Clean up unused code * Clean up support interface * Rename the compile output requests to mark them DEPRECATED --------- Co-authored-by: Yong He <yonghe@outlook.com>
-rw-r--r--tools/render-test/render-test-main.cpp43
-rw-r--r--tools/render-test/slang-support.cpp39
-rw-r--r--tools/render-test/slang-support.h30
3 files changed, 32 insertions, 80 deletions
diff --git a/tools/render-test/render-test-main.cpp b/tools/render-test/render-test-main.cpp
index a167a4a27..b0d6c44e0 100644
--- a/tools/render-test/render-test-main.cpp
+++ b/tools/render-test/render-test-main.cpp
@@ -154,28 +154,28 @@ protected:
struct AssignValsFromLayoutContext
{
IDevice* device;
- slang::ISession* slangSession;
+ slang::IComponentType* slangComponent;
ShaderOutputPlan& outputPlan;
TestResourceContext& resourceContext;
- slang::ProgramLayout* slangReflection;
IAccelerationStructure* accelerationStructure;
AssignValsFromLayoutContext(
IDevice* device,
- slang::ISession* slangSession,
+ slang::IComponentType* slangComponent,
ShaderOutputPlan& outputPlan,
TestResourceContext& resourceContext,
- slang::ProgramLayout* slangReflection,
IAccelerationStructure* accelerationStructure)
: device(device)
- , slangSession(slangSession)
+ , slangComponent(slangComponent)
, outputPlan(outputPlan)
, resourceContext(resourceContext)
- , slangReflection(slangReflection)
, accelerationStructure(accelerationStructure)
{
}
+ slang::ProgramLayout* slangReflection() { return slangComponent->getLayout(); }
+ slang::ISession* slangSession() { return slangComponent->getSession(); }
+
void maybeAddOutput(
ShaderCursor const& dstCursor,
ShaderInputLayout::Val* srcVal,
@@ -389,7 +389,7 @@ struct AssignValsFromLayoutContext
// If the input line specified the name of the type
// to allocate, then we use it directly.
//
- slangType = slangReflection->findTypeByName(typeName.getBuffer());
+ slangType = slangReflection()->findTypeByName(typeName.getBuffer());
}
else
{
@@ -418,7 +418,7 @@ struct AssignValsFromLayoutContext
ComPtr<IShaderObject> shaderObject;
device->createShaderObject(
- slangSession,
+ slangSession(),
slangType,
ShaderObjectContainerType::None,
shaderObject.writeRef());
@@ -437,7 +437,7 @@ struct AssignValsFromLayoutContext
List<slang::SpecializationArg> args;
for (auto& typeName : srcVal->typeArgs)
{
- auto slangType = slangReflection->findTypeByName(typeName.getBuffer());
+ auto slangType = slangReflection()->findTypeByName(typeName.getBuffer());
if (!slangType)
{
StdWriters::getError().print(
@@ -516,42 +516,30 @@ struct AssignValsFromLayoutContext
}
};
-SlangResult _assignVarsFromLayout(
+static SlangResult _assignVarsFromLayout(
IDevice* device,
- slang::ISession* slangSession,
+ slang::IComponentType* slangComponent,
IShaderObject* shaderObject,
ShaderInputLayout const& layout,
ShaderOutputPlan& ioOutputPlan,
TestResourceContext& ioResourceContext,
- slang::ProgramLayout* slangReflection,
IAccelerationStructure* accelerationStructure)
{
- AssignValsFromLayoutContext context(
- device,
- slangSession,
- ioOutputPlan,
- ioResourceContext,
- slangReflection,
- accelerationStructure);
+ AssignValsFromLayoutContext
+ context(device, slangComponent, ioOutputPlan, ioResourceContext, accelerationStructure);
ShaderCursor rootCursor = ShaderCursor(shaderObject);
return context.assign(rootCursor, layout.rootVal);
}
Result RenderTestApp::applyBinding(IShaderObject* rootObject)
{
- auto slangReflection = (slang::ProgramLayout*)spGetReflection(
- m_compilationOutput.output.getRequestForReflection());
- ComPtr<slang::ISession> slangSession;
- m_compilationOutput.output.m_requestForKernels->getSession(slangSession.writeRef());
-
return _assignVarsFromLayout(
m_device,
- slangSession,
+ m_compilationOutput.output.slangProgram,
rootObject,
m_compilationOutput.layout,
m_outputPlan,
m_resourceContext,
- slangReflection,
m_topLevelAccelerationStructure);
}
@@ -1086,9 +1074,6 @@ Result RenderTestApp::update()
m_options.shaderType == Options::ShaderProgramType::GraphicsMeshCompute ||
m_options.shaderType == Options::ShaderProgramType::GraphicsTaskMeshCompute)
{
- auto request = m_compilationOutput.output.getRequestForReflection();
- auto slangReflection = (slang::ShaderReflection*)spGetReflection(request);
-
SLANG_RETURN_ON_FAIL(writeBindingOutput(m_options.outputPath));
}
else
diff --git a/tools/render-test/slang-support.cpp b/tools/render-test/slang-support.cpp
index 368ee0390..22a745d1f 100644
--- a/tools/render-test/slang-support.cpp
+++ b/tools/render-test/slang-support.cpp
@@ -36,16 +36,15 @@ void ShaderCompilerUtil::Output::reset()
}
session = nullptr;
- m_requestForKernels = nullptr;
- m_extraRequestForReflection = nullptr;
+ m_requestDEPRECATED = nullptr;
}
-/* static */ SlangResult ShaderCompilerUtil::_compileProgramImpl(
+static SlangResult _compileProgramImpl(
slang::IGlobalSession* globalSession,
const Options& options,
- const Input& input,
+ const ShaderCompilerUtil::Input& input,
const ShaderCompileRequest& request,
- Output& out)
+ ShaderCompilerUtil::Output& out)
{
out.reset();
@@ -58,7 +57,7 @@ void ShaderCompilerUtil::Output::reset()
SLANG_ALLOW_DEPRECATED_BEGIN
globalSession->createCompileRequest(slangRequest.writeRef());
SLANG_ALLOW_DEPRECATED_END
- out.m_requestForKernels = slangRequest;
+ out.m_requestDEPRECATED = slangRequest;
out.session = globalSession;
bool hasRepro = false;
@@ -303,12 +302,12 @@ void ShaderCompilerUtil::Output::reset()
return SLANG_OK;
}
-/* static */ SlangResult ShaderCompilerUtil::compileProgram(
+static SlangResult compileProgram(
slang::IGlobalSession* globalSession,
const Options& options,
- const Input& input,
+ const ShaderCompilerUtil::Input& input,
const ShaderCompileRequest& request,
- Output& out)
+ ShaderCompilerUtil::Output& out)
{
if (input.passThrough == SLANG_PASS_THROUGH_NONE)
{
@@ -333,7 +332,7 @@ void ShaderCompilerUtil::Output::reset()
// compile in another pass using the desired downstream compiler
// so that we can get the refleciton information we need.
//
- Output slangOutput;
+ ShaderCompilerUtil::Output slangOutput;
if (canUseSlangForPrecompile)
{
ShaderCompilerUtil::Input slangInput = input;
@@ -354,17 +353,16 @@ void ShaderCompilerUtil::Output::reset()
//
SLANG_RETURN_ON_FAIL(_compileProgramImpl(globalSession, options, input, request, out));
- out.m_extraRequestForReflection = slangOutput.getRequestForReflection();
+ out.m_requestDEPRECATED = slangOutput.m_requestDEPRECATED;
out.desc.slangGlobalScope = slangOutput.desc.slangGlobalScope;
- slangOutput.m_requestForKernels = nullptr;
+ slangOutput.m_requestDEPRECATED = nullptr;
return SLANG_OK;
}
}
-/* static */ SlangResult ShaderCompilerUtil::readSource(
- const String& inSourcePath,
- List<char>& outSourceText)
+// Helper for compileWithLayout
+/* static */ SlangResult readSource(const String& inSourcePath, List<char>& outSourceText)
{
// Read in the source code
FILE* sourceFile = fopen(inSourcePath.getBuffer(), "rb");
@@ -392,8 +390,8 @@ void ShaderCompilerUtil::Output::reset()
/* static */ SlangResult ShaderCompilerUtil::compileWithLayout(
slang::IGlobalSession* globalSession,
const Options& options,
- const ShaderCompilerUtil::Input& input,
- OutputAndLayout& output)
+ const Input& input,
+ ShaderCompilerUtil::OutputAndLayout& output)
{
String sourcePath = options.sourcePath;
auto shaderType = options.shaderType;
@@ -531,12 +529,7 @@ void ShaderCompilerUtil::Output::reset()
c.idOverride = conformance.idOverride;
compileRequest.typeConformances.add(c);
}
- return ShaderCompilerUtil::compileProgram(
- globalSession,
- options,
- input,
- compileRequest,
- output.output);
+ return compileProgram(globalSession, options, input, compileRequest, output.output);
}
} // namespace renderer_test
diff --git a/tools/render-test/slang-support.h b/tools/render-test/slang-support.h
index d5574e903..e105b6b86 100644
--- a/tools/render-test/slang-support.h
+++ b/tools/render-test/slang-support.h
@@ -67,17 +67,7 @@ struct ShaderCompilerUtil
ComPtr<slang::IComponentType> slangProgram;
ShaderProgramDesc desc = {};
- /// Compile request that owns the lifetime of compiled kernel code.
- ComPtr<SlangCompileRequest> m_requestForKernels = nullptr;
-
- /// Compile request that owns the lifetime of reflection information.
- ComPtr<SlangCompileRequest> m_extraRequestForReflection = nullptr;
-
- SlangCompileRequest* getRequestForKernels() const { return m_requestForKernels; }
- SlangCompileRequest* getRequestForReflection() const
- {
- return m_extraRequestForReflection ? m_extraRequestForReflection : m_requestForKernels;
- }
+ ComPtr<SlangCompileRequest> m_requestDEPRECATED = nullptr;
SlangSession* session = nullptr;
};
@@ -89,28 +79,12 @@ struct ShaderCompilerUtil
Slang::String sourcePath;
};
+ // Wrapper for compileProgram
static SlangResult compileWithLayout(
slang::IGlobalSession* globalSession,
const Options& options,
const ShaderCompilerUtil::Input& input,
OutputAndLayout& output);
-
- static SlangResult readSource(
- const Slang::String& inSourcePath,
- Slang::List<char>& outSourceText);
-
- static SlangResult _compileProgramImpl(
- slang::IGlobalSession* globalSession,
- const Options& options,
- const Input& input,
- const ShaderCompileRequest& request,
- Output& out);
- static SlangResult compileProgram(
- slang::IGlobalSession* globalSession,
- const Options& options,
- const Input& input,
- const ShaderCompileRequest& request,
- Output& out);
};