From 2f44d9e01234911dd563f0456b9d861fd8db286d Mon Sep 17 00:00:00 2001 From: Yong He Date: Mon, 18 Oct 2021 12:19:45 -0700 Subject: GFX: implement mutable shader objects. (#1963) * GFX: implement mutable shader objects. * Revert unnecessary changes * Revert more changes. * Fix clang errors. * Fix clang/gcc errors. * Fix clang errors. * Remove CPU test. * Fix after merge. * Fix after merge. * Remove gl test * Code review fixes. * Fixing all vk validation errors. * Flush test output more often. * Fix a crash in `specializeDynamicAssociatedTypeLookup`. * temporarily disable std-lib-serialize test to see what happens * Fix crashes. * Make sure cpu gfx unit tests are properly disabled on TeamCity. * Disable cpu test. * Fix. * Fix cuda. * Disable nv-ray-tracing-motion-blur Co-authored-by: Yong He --- tools/gfx/debug-layer.cpp | 59 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 53 insertions(+), 6 deletions(-) (limited to 'tools/gfx/debug-layer.cpp') diff --git a/tools/gfx/debug-layer.cpp b/tools/gfx/debug-layer.cpp index bab564f14..5f5b0505e 100644 --- a/tools/gfx/debug-layer.cpp +++ b/tools/gfx/debug-layer.cpp @@ -563,6 +563,26 @@ Result DebugDevice::createShaderObject( return result; } +Result DebugDevice::createMutableShaderObject( + slang::TypeReflection* type, + ShaderObjectContainerType containerType, + IShaderObject** outShaderObject) +{ + SLANG_GFX_API_FUNC; + + RefPtr outObject = new DebugShaderObject(); + auto typeName = type->getName(); + auto result = + baseObject->createMutableShaderObject(type, containerType, outObject->baseObject.writeRef()); + outObject->m_typeName = typeName; + outObject->m_device = this; + outObject->m_slangType = type; + if (SLANG_FAILED(result)) + return result; + returnComPtr(outShaderObject, outObject); + return result; +} + Result DebugDevice::createProgram(const IShaderProgram::Desc& desc, IShaderProgram** outProgram) { SLANG_GFX_API_FUNC; @@ -863,8 +883,10 @@ Result DebugComputeCommandEncoder::bindPipeline( SLANG_GFX_API_FUNC; auto innerState = static_cast(state)->baseObject; - auto result = - baseObject->bindPipeline(innerState, commandBuffer->rootObject.baseObject.writeRef()); + IShaderObject* innerRootObject = nullptr; + commandBuffer->rootObject.reset(); + auto result = baseObject->bindPipeline(innerState, &innerRootObject); + commandBuffer->rootObject.baseObject.attach(innerRootObject); *outRootShaderObject = &commandBuffer->rootObject; return result; } @@ -895,8 +917,10 @@ Result DebugRenderCommandEncoder::bindPipeline( SLANG_GFX_API_FUNC; auto innerState = static_cast(state)->baseObject; - auto result = - baseObject->bindPipeline(innerState, commandBuffer->rootObject.baseObject.writeRef()); + IShaderObject* innerRootObject = nullptr; + commandBuffer->rootObject.reset(); + auto result = baseObject->bindPipeline(innerState, &innerRootObject); + commandBuffer->rootObject.baseObject.attach(innerRootObject); *outRootShaderObject = &commandBuffer->rootObject; return result; } @@ -1142,7 +1166,10 @@ void DebugRayTracingCommandEncoder::bindPipeline( { SLANG_GFX_API_FUNC; auto innerPipeline = getInnerObj(state); - baseObject->bindPipeline(innerPipeline, commandBuffer->rootObject.baseObject.writeRef()); + IShaderObject* innerRootObject = nullptr; + commandBuffer->rootObject.reset(); + baseObject->bindPipeline(innerPipeline, &innerRootObject); + commandBuffer->rootObject.baseObject.attach(innerRootObject); *outRootObject = &commandBuffer->rootObject; } @@ -1393,10 +1420,21 @@ Result DebugShaderObject::setSpecializationArgs( const slang::SpecializationArg* args, uint32_t count) { - return baseObject->setSpecializationArgs(offset, args, count); } +Result DebugShaderObject::getCurrentVersion( + ITransientResourceHeap* transientHeap, IShaderObject** outObject) +{ + ComPtr innerObject; + SLANG_RETURN_ON_FAIL(baseObject->getCurrentVersion(getInnerObj(transientHeap), innerObject.writeRef())); + RefPtr debugShaderObject = new DebugShaderObject(); + debugShaderObject->baseObject = innerObject; + debugShaderObject->m_typeName = innerObject->getElementTypeLayout()->getName(); + returnComPtr(outObject, debugShaderObject); + return SLANG_OK; +} + DebugObjectBase::DebugObjectBase() { static uint64_t uidCounter = 0; @@ -1413,6 +1451,15 @@ Result DebugRootShaderObject::setSpecializationArgs( return baseObject->setSpecializationArgs(offset, args, count); } +void DebugRootShaderObject::reset() +{ + m_entryPoints.clear(); + m_objects.Clear(); + m_resources.Clear(); + m_samplers.Clear(); + baseObject.detach(); +} + Result DebugQueryPool::getResult(SlangInt index, SlangInt count, uint64_t* data) { SLANG_GFX_API_FUNC; -- cgit v1.2.3