Skip to content

Adsk Contrib - Vulkan support#2176

Merged
doug-walker merged 20 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:horschm/VulkanSupport
Sep 26, 2025
Merged

Adsk Contrib - Vulkan support#2176
doug-walker merged 20 commits into
AcademySoftwareFoundation:mainfrom
autodesk-forks:horschm/VulkanSupport

Conversation

@michaelHADSK
Copy link
Copy Markdown
Contributor

This PR adds Vulkan support to OCIO.

  • Added GPU_LANGUAGE_GLSL_VK_4_6 and the corresponding functionality
  • Split up declare shader code into textures and parameters
  • Added code to add vulkan uniform buffer code around variables
  • Functions to add textures now return the index of the texture which is used as the binding index in the shader code
  • UniformData now has a bufferOffset to be able to copy the uniform data to the right place in the uniform buffer
  • There's a new function to return the size of the generated uniform buffer
  • There are new functions to to set and get the Vulkan descriptor set index and texture binding start index
  • Added a castToBool method to the GPUShaderText. Support for bools in uniform buffers is unfortunately not well defined/supported in Vulkan, that's why they are declared as int variables. Since there is no implicit cast to bool from int in GLSL, I had to add the explicit cast at some places. This is not so nice because other coders need to be aware that this is required for Vulkan, other ideas on how to deal with that are appreciated.

@mrvux
Copy link
Copy Markdown

mrvux commented Jul 27, 2025

As requested, here is my feedback on the PR (forked the branch to check the code).
It's very similar to what I did in my personal fork for dx11, with a few key differences (given the fact that vulkan GPU_LANGUAGE_GLSL_VK_4_6 got added it could go away with it, in my case it was not possible):

  1. In case of dx11/dx12, sampler states live in a separate register space than resources, so another index was required

void setDescriptorSetIndex(unsigned index, unsigned textureBindingStart = 1);

so for direct3d an additional samplerBindingStart is required.

Also note that registers in Direct3d are zero indexed

Texture2D myLut : register(t0); // (up to 127) SamplerState myLutSampler : register(s2); //up to 15

  1. Given that in my case another enum was not required and I wanted not to break existing implementations (to have the implementation use GPU_LANGUAGE_HLSL_SM_5_0).

There is another function in GpuShaderCreator called :

void setUseExplicitBindings(bool useExplicitBindings);

This is off by default and keeps explicit implementations to use the default "automatic" bindings" (eg : current implementation) , and use explicit as an Opt-In.

  1. The change, given we add samplerBindingStart in the gpu creator, would fix Direct3d12 in a nearly identical way as per Vulkan:

kw << "layout(set=" << descriptorSetIndex << ", binding = " << textureIndex << ") ";

becomes :

t << "Texture" << N << "D " << textureName : register(t" << textureIndex << ", space" << descriptorSetIndex << ");"

It would require a new enum in that case GPU_LANGUAGE_HLSL_SM_5_1

But given that it would not break the GpuCreator interface, this could be implemented at a later stage with no risk of breaking existing implementations.

@doug-walker doug-walker changed the title Vulkan support Adsk Contrib - Vulkan support Jul 27, 2025
Comment thread src/OpenColorIO/GpuShaderUtils.cpp Outdated
michaelHADSK and others added 18 commits September 19, 2025 17:55
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
…tart index.

Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Co-authored-by: Aleksi Sapon <aleksi.sapon@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Comment thread tests/cpu/GpuShader_tests.cpp Outdated
Copy link
Copy Markdown
Collaborator

@cozdas cozdas left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just needs the broken Windows unit tests fixed. Otherwise LGTM!

michaelHADSK and others added 2 commits September 26, 2025 14:51
Signed-off-by: Michael Horsch <michael.horsch@autodesk.com>
Copy link
Copy Markdown
Collaborator

@doug-walker doug-walker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a very welcome feature, thank you so much @michaelHADSK !

@doug-walker doug-walker merged commit 337f7c7 into AcademySoftwareFoundation:main Sep 26, 2025
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants