cleaned up code around
authorkapoorv <vipul.kapoor@autodesk.com>
Wed, 10 Jan 2024 16:08:30 +0000 (11:08 -0500)
committerkapoorv <vipul.kapoor@autodesk.com>
Wed, 10 Jan 2024 16:09:14 +0000 (11:09 -0500)
1. VkPipelineVertexInputStateCreateInfo (following latest fixes proposed by Pixar)
2. Instance Layer Extensions (following latest fixes proposed by Pixar)
3. UV flipping fix in shader selection for Vulkan (following latest fixes proposed by Adobe)
4. Undoing temp code aound flipping color correction UVs flip

(cherry picked from commit db0a46bede5b9504bb6954dc8ac7b1b5d6e5f364)

pxr/imaging/hdx/colorCorrectionTask.cpp
pxr/imaging/hgiVulkan/graphicsPipeline.cpp
pxr/imaging/hgiVulkan/instance.cpp
pxr/imaging/hgiVulkan/shaderSection.cpp

index 6a724e9241df53b87f9f259df0491cdb5ac01e0f..4e94fffb05f6da780770fa227c3fb04d4634e289 100644 (file)
@@ -883,12 +883,12 @@ HdxColorCorrectionTask::_CreateBufferResources()
               {  3, -1, 0, 1,     2, 0 } };
 
     // Vulkan back-end needs the UVs inverted along the y axis
-    if (_GetHgi()->GetAPIName() == HgiTokens->Vulkan)
-    {
-        vertData[0][5] = 1.0f - vertData[0][5];
-        vertData[1][5] = 1.0f - vertData[1][5];
-        vertData[2][5] = 1.0f - vertData[2][5];
-    }
+    //if (_GetHgi()->GetAPIName() == HgiTokens->Vulkan)
+    //{
+    //    vertData[0][5] = 1.0f - vertData[0][5];
+    //    vertData[1][5] = 1.0f - vertData[1][5];
+    //    vertData[2][5] = 1.0f - vertData[2][5];
+    //}
 
     HgiBufferDesc vboDesc;
     vboDesc.debugName = "HdxColorCorrectionTask VertexBuffer";
index b8c76871acfdf7de337f39f0f1470cbe0c386eb7..dfe32ba424e0c181e5bad0ffd642afcb4dd968c3 100755 (executable)
@@ -132,19 +132,12 @@ HgiVulkanGraphicsPipeline::HgiVulkanGraphicsPipeline(
         vertBufs.push_back(std::move(vib));
     }
 
-    VkPipelineVertexInputDivisorStateCreateInfoEXT vertexInputDivisor =
-        {VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
-    vertexInputDivisor.pVertexBindingDivisors = vertBindingDivisors.data();
-    vertexInputDivisor.vertexBindingDivisorCount =
-        (uint32_t) vertBindingDivisors.size();
-
     VkPipelineVertexInputStateCreateInfo vertexInput =
         {VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO};
     vertexInput.pVertexAttributeDescriptions = vertAttrs.data();
     vertexInput.vertexAttributeDescriptionCount = (uint32_t) vertAttrs.size();
     vertexInput.pVertexBindingDescriptions = vertBufs.data();
     vertexInput.vertexBindingDescriptionCount = (uint32_t) vertBufs.size();
-    vertexInput.pNext = (vertBindingDivisors.size() > 0) ? &vertexInputDivisor : nullptr;
     
     pipeCreateInfo.pVertexInputState = &vertexInput;
 
index 58f086cecfa240d630869f8122d19d79f229cedb..48ee7bc615d457f66cc89f4a23af941ab0625776 100755 (executable)
@@ -67,15 +67,10 @@ HgiVulkanInstance::HgiVulkanInstance()
         VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME,
     };
 
-    std::vector<const char*> instanceLayerList;
     // Enable validation layers extension.
     // Requires VK_LAYER_PATH to be set.
     if (HgiVulkanIsDebugEnabled()) {
         extensions.push_back(VK_EXT_DEBUG_UTILS_EXTENSION_NAME);
-        instanceLayerList.push_back("VK_LAYER_KHRONOS_validation");
-
-        createInfo.ppEnabledLayerNames = instanceLayerList.data();
-        createInfo.enabledLayerCount = (uint32_t)instanceLayerList.size();
     }
 
     createInfo.ppEnabledExtensionNames = extensions.data();
index 29c65b28191af285f031f92338fe30f92f7ec9e6..48daab62828dcb1a863ba39b9bbdba7c5227d14c 100644 (file)
@@ -351,10 +351,16 @@ HgiVulkanTextureShaderSection::VisitGlobalFunctionDefinitions(std::ostream &ss)
     if (_writable) {
         // Write a function that lets you write to the texture with 
         // HgiSet_texName(uv, data).
+        const std::string arrayIndex = (_arraySize > 0) ? "[index]" : "";
         ss << "void HgiSet_";
         WriteIdentifier(ss);
         ss << "(" << intCoordType << " uv, vec4 data) {\n";
-        ss << "    ";
+
+        if (sizeDim >= 2) {
+            ss << sizeType << " texSize = imageSize("; WriteIdentifier(ss);
+            ss << ");\n";
+            ss << "uv.y = texSize.y - 1 - uv.y;\n";
+        }
         ss << "imageStore(";
         WriteIdentifier(ss);
         ss << ", uv, data);\n";
@@ -379,7 +385,11 @@ HgiVulkanTextureShaderSection::VisitGlobalFunctionDefinitions(std::ostream &ss)
         ss << " HgiGet_";
         WriteIdentifier(ss);
         ss << "(" << arrayInput << floatCoordType << " uv) {\n";
-        ss << "    ";
+
+        if (sizeDim >= 2) {
+            ss << "uv.y = 1.0 - uv.y;\n";
+        }
+
         _WriteSampledDataType(ss);
         ss << " result = texture(";
         WriteIdentifier(ss);
@@ -402,7 +412,11 @@ HgiVulkanTextureShaderSection::VisitGlobalFunctionDefinitions(std::ostream &ss)
         ss << " HgiTextureLod_";
         WriteIdentifier(ss);
         ss << "(" << arrayInput << floatCoordType << " coord, float lod) {\n";
-        ss << "    ";
+        if (sizeDim >= 2) {
+            ss << sizeType << " texSize = textureSize("; WriteIdentifier(ss);
+            ss << arrayIndex << ", 0);\n";
+            ss << " coord.y = float(texSize.y-1) - coord.y;\n";
+        }
         ss << "return textureLod(";
         WriteIdentifier(ss);
         ss << arrayIndex << ", coord, lod);\n";
@@ -414,7 +428,11 @@ HgiVulkanTextureShaderSection::VisitGlobalFunctionDefinitions(std::ostream &ss)
             ss << " HgiTexelFetch_";
             WriteIdentifier(ss);
             ss << "(" << arrayInput << intCoordType << " coord) {\n";
-            ss << "    ";
+            if (sizeDim >= 2) {
+                ss << sizeType << " texSize = textureSize("; WriteIdentifier(ss);
+                ss << arrayIndex << ", 0);\n";
+                ss << "coord.y = texSize.y - 1 - coord.y;\n";
+            }
             _WriteSampledDataType(ss);
             ss << " result = texelFetch(";
             WriteIdentifier(ss);