Skip to content

Commit

Permalink
Use SLANG_ASSERT
Browse files Browse the repository at this point in the history
  • Loading branch information
cheneym2 committed Feb 3, 2025
1 parent e82142b commit a55f68a
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 11 deletions.
2 changes: 1 addition & 1 deletion tools/gfx/d3d12/d3d12-shader-program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Result ShaderProgramImpl::createShaderModule(
ShaderBinary shaderBin;
shaderBin.stage = entryPointInfo->getStage();
shaderBin.entryPointInfo = entryPointInfo;
assert(kernelCodes.getCount() == 1); // Only one kernel code is supported for now
SLANG_ASSERT(kernelCodes.getCount() == 1);
shaderBin.code.addRange(
reinterpret_cast<const uint8_t*>(kernelCodes[0]->getBufferPointer()),
(Index)kernelCodes[0]->getBufferSize());
Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/metal/metal-shader-program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Result ShaderProgramImpl::createShaderModule(
Module module;
module.stage = entryPointInfo->getStage();
module.entryPointName = entryPointInfo->getNameOverride();
assert(kernelCodes.getCount() == 1);
SLANG_ASSERT(kernelCodes.getCount() == 1);
module.code = kernelCodes[0];


Expand Down
8 changes: 4 additions & 4 deletions tools/gfx/renderer-shared.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1110,15 +1110,15 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
{
auto stage = entryPointInfo->getStage();

List<ComPtr<ISlangBlob> > kernelCodes;
ComPtr<ISlangBlob> kernelCode;
List<ComPtr<ISlangBlob>> kernelCodes;
{
ComPtr<ISlangBlob> spirv;
ComPtr<ISlangBlob> diagnostics;
auto compileResult = device->getEntryPointCodeFromShaderCache(
entryPointComponent,
entryPointIndex,
0,
kernelCode.writeRef(),
spirv.writeRef(),
diagnostics.writeRef());
if (diagnostics)
{
Expand All @@ -1131,7 +1131,7 @@ Result ShaderProgramBase::compileShaders(RendererBase* device)
(char*)diagnostics->getBufferPointer());
}
SLANG_RETURN_ON_FAIL(compileResult);
kernelCodes.add(kernelCode);
kernelCodes.add(spirv);
}

// If target precompilation was used, kernelCode may only represent the
Expand Down
2 changes: 1 addition & 1 deletion tools/gfx/vulkan/vk-pipeline-state.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ Result PipelineStateImpl::createVKComputePipelineState()

VkComputePipelineCreateInfo computePipelineInfo = {
VK_STRUCTURE_TYPE_COMPUTE_PIPELINE_CREATE_INFO};
assert(programImpl->m_stageCreateInfos.getCount() == 1);
SLANG_ASSERT(programImpl->m_stageCreateInfos.getCount() == 1);
computePipelineInfo.stage = programImpl->m_stageCreateInfos[0];
computePipelineInfo.layout = programImpl->m_rootObjectLayout->m_pipelineLayout;

Expand Down
4 changes: 0 additions & 4 deletions tools/gfx/vulkan/vk-shader-program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ Result ShaderProgramImpl::createShaderModule(
slang::EntryPointReflection* entryPointInfo,
List<ComPtr<ISlangBlob>> kernelCodes)
{
//for (auto kernelCode : kernelCodes)
// m_codeBlobs.add(kernelCode);

ComPtr<ISlangBlob> linkedKernel = LinkWithSPIRVTools(kernelCodes);
m_codeBlobs.add(linkedKernel);

Expand All @@ -130,7 +127,6 @@ Result ShaderProgramImpl::createShaderModule(
linkedKernel,
(VkShaderStageFlagBits)VulkanUtil::getShaderStage(entryPointInfo->getStage()),
shaderModule));

m_entryPointNames.add(realEntryPointName);
m_modules.add(shaderModule);
return SLANG_OK;
Expand Down

0 comments on commit a55f68a

Please sign in to comment.