MCPcopy Create free account
hub / github.com/NVIDIA-RTX/RTXNTC / ExecuteComputePass

Method ExecuteComputePass

libraries/ntc-utils/src/GraphicsDecompressionPass.cpp:232–293  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

230}
231
232bool GraphicsDecompressionPass::ExecuteComputePass(nvrhi::ICommandList* commandList, ntc::ComputePassDesc& computePass)
233{
234 // Create the pipeline for this shader if it doesn't exist yet
235 auto& pipeline = m_pipelines[computePass.computeShader];
236 if (!pipeline)
237 {
238 nvrhi::ShaderHandle computeShader = m_device->createShader(nvrhi::ShaderDesc().setShaderType(nvrhi::ShaderType::Compute),
239 computePass.computeShader,
240 computePass.computeShaderSize);
241
242 nvrhi::ComputePipelineDesc pipelineDesc;
243 pipelineDesc
244 .setComputeShader(computeShader)
245 .addBindingLayout(m_bindingLayout)
246 .addBindingLayout(m_bindlessLayout);
247
248 pipeline = m_device->createComputePipeline(pipelineDesc);
249
250 if (!pipeline)
251 return false;
252 }
253
254 // Create the constant buffer if it doesn't exist yet or if it is too small (which shouldn't happen currently)
255 if (!m_constantBuffer || m_constantBuffer->getDesc().byteSize < computePass.constantBufferSize)
256 {
257 nvrhi::BufferDesc constantBufferDesc;
258 constantBufferDesc
259 .setByteSize(computePass.constantBufferSize)
260 .setDebugName("DecompressionConstants")
261 .setIsConstantBuffer(true)
262 .setIsVolatile(true)
263 .setMaxVersions(NTC_MAX_MIPS * NTC_MAX_CHANNELS);
264
265 m_constantBuffer = m_device->createBuffer(constantBufferDesc);
266
267 if (!m_constantBuffer)
268 return false;
269 }
270
271 nvrhi::BindingSetDesc bindingSetDesc;
272 bindingSetDesc
273 .addItem(nvrhi::BindingSetItem::ConstantBuffer(NTC_BINDING_DECOMPRESSION_CONSTANT_BUFFER, m_constantBuffer))
274 .addItem(nvrhi::BindingSetItem::Texture_SRV(NTC_BINDING_DECOMPRESSION_LATENT_TEXTURE, m_latentTexture))
275 .addItem(nvrhi::BindingSetItem::RawBuffer_SRV(NTC_BINDING_DECOMPRESSION_WEIGHT_BUFFER, m_weightBuffer))
276 .addItem(nvrhi::BindingSetItem::Sampler(NTC_BINDING_DECOMPRESSION_LATENT_SAMPLER, m_latentSampler));
277 nvrhi::BindingSetHandle bindingSet = m_bindingCache.GetOrCreateBindingSet(bindingSetDesc, m_bindingLayout);
278 if (!bindingSet)
279 return false;
280
281 // Write the constant buffer
282 commandList->writeBuffer(m_constantBuffer, computePass.constantBufferData, computePass.constantBufferSize);
283
284 // Execute the compute shader for decompression
285 nvrhi::ComputeState state;
286 state.setPipeline(pipeline)
287 .addBindingSet(bindingSet)
288 .addBindingSet(m_descriptorTable);
289 commandList->setComputeState(state);

Callers 11

DecompressWithGapiMethod · 0.45
OptimizeBlockCompressionFunction · 0.45
TranscodeTilesMethod · 0.45
TranscodeMaterialMethod · 0.45
CompareTwoImagesFunction · 0.45
CompressWithNtcFunction · 0.45
CompressWithNvttFunction · 0.45

Calls

no outgoing calls

Tested by 3

CompareTwoImagesFunction · 0.36
CompressWithNtcFunction · 0.36
CompressWithNvttFunction · 0.36