Skip to content

Commit

Permalink
writability improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
Thor Hjalmarsson committed Sep 23, 2022
1 parent cde066d commit 9a8dd1d
Show file tree
Hide file tree
Showing 9 changed files with 13 additions and 5 deletions.
3 changes: 2 additions & 1 deletion pxr/imaging/hdSt/domeLightComputations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -240,13 +240,14 @@ HdSt_DomeLightComputationGPU::Execute(
texBind0.stageUsage = HgiShaderStageCompute;
texBind0.textures.push_back(srcTextureName);
texBind0.samplers.push_back(srcSamplerName);
texBind0.readOnly = true;
texBind0.writable = false;
texBind0.resourceType = HgiBindResourceTypeCombinedSamplerImage;
resourceDesc.textures.push_back(std::move(texBind0));

HgiTextureBindDesc texBind1;
texBind1.bindingIndex = 1;
texBind1.stageUsage = HgiShaderStageCompute;
texBind1.writable = true;
texBind1.textures.push_back(dstTextureView->GetViewTexture());
texBind1.samplers.push_back(srcSamplerName);
texBind1.resourceType = HgiBindResourceTypeStorageImage;
Expand Down
2 changes: 2 additions & 0 deletions pxr/imaging/hdSt/resourceBinder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1123,6 +1123,7 @@ HdSt_ResourceBinder::GetTextureBindingDesc(
texelDesc.samplers = { texelSampler };
texelDesc.resourceType = HgiBindResourceTypeSampledImage;
texelDesc.bindingIndex = binding.GetTextureUnit();
texelDesc.writable = false;
bindingsDesc->textures.push_back(std::move(texelDesc));
}

Expand All @@ -1146,6 +1147,7 @@ HdSt_ResourceBinder::GetTextureWithLayoutBindingDesc(
layoutDesc.samplers = { };
layoutDesc.resourceType = HgiBindResourceTypeSampledImage;
layoutDesc.bindingIndex = layoutBinding.GetTextureUnit();
layoutDesc.writable = false;
bindingsDesc->textures.push_back(std::move(layoutDesc));
}

Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/hdSt/unitTestHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,7 @@ HdSt_TextureTestDriver::_CreateTextureBindings(
HgiTextureBindDesc texBindDesc;
texBindDesc.bindingIndex = 0;
texBindDesc.stageUsage = HgiShaderStageFragment;
texBindDesc.writable = true;
texBindDesc.textures.push_back(textureHandle);
if (samplerHandle) {
texBindDesc.samplers.push_back(samplerHandle);
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/hdx/colorCorrectionTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -348,15 +348,16 @@ HdxColorCorrectionTask::_CreateResourceBindings(
HgiTextureBindDesc texBind0;
texBind0.bindingIndex = 0;
texBind0.stageUsage = HgiShaderStageFragment;
texBind0.writable = false;
texBind0.textures.push_back(aovTexture);
texBind0.samplers.push_back(_sampler);
texBind0.readOnly = true;
resourceDesc.textures.push_back(std::move(texBind0));

if (useOCIO && _texture3dLUT) {
HgiTextureBindDesc texBind1;
texBind1.bindingIndex = 1;
texBind1.stageUsage = HgiShaderStageFragment;
texBind1.writable = false;
texBind1.textures.push_back(_texture3dLUT);
texBind1.samplers.push_back(_sampler);
resourceDesc.textures.push_back(std::move(texBind1));
Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/hdx/fullscreenShader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,7 @@ HdxFullscreenShader::_CreateResourceBindings(TextureMap const& textures)
HgiTextureBindDesc texBind;
texBind.bindingIndex = bindSlots++;
texBind.stageUsage = HgiShaderStageFragment;
texBind.writable = false;
texBind.textures.push_back(texHandle);
texBind.samplers.push_back(_sampler);
resourceDesc.textures.push_back(std::move(texBind));
Expand Down
1 change: 1 addition & 0 deletions pxr/imaging/hdx/visualizeAovTask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,7 @@ HdxVisualizeAovTask::_CreateResourceBindings(
HgiTextureBindDesc texBind0;
texBind0.bindingIndex = 0;
texBind0.stageUsage = HgiShaderStageFragment;
texBind0.writable = false;
texBind0.textures.push_back(inputAovTexture);
texBind0.samplers.push_back(_sampler);
resourceDesc.textures.push_back(std::move(texBind0));
Expand Down
3 changes: 2 additions & 1 deletion pxr/imaging/hgi/resourceBindings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ bool operator==(
lhs.resourceType == rhs.resourceType &&
lhs.bindingIndex == rhs.bindingIndex &&
lhs.stageUsage == rhs.stageUsage &&
lhs.samplers == rhs.samplers;
lhs.samplers == rhs.samplers &&
lhs.writable == rhs.writable;
}

bool operator!=(
Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hgi/resourceBindings.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ struct HgiTextureBindDesc
HgiBindResourceType resourceType;
uint32_t bindingIndex;
HgiShaderStage stageUsage;
bool readOnly;
bool writable;
};
using HgiTextureBindDescVector = std::vector<HgiTextureBindDesc>;

Expand Down
2 changes: 1 addition & 1 deletion pxr/imaging/hgiMetal/resourceBindings.mm
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@
else {
usageFlags = MTLResourceUsageRead;
}
if (!texDesc.readOnly) {
if (texDesc.writable) {
usageFlags = usageFlags | MTLResourceUsageWrite;
}
[renderEncoder useResource:metalTexture
Expand Down

0 comments on commit 9a8dd1d

Please sign in to comment.