Added comments and more format fixes
This commit is contained in:
@@ -16,6 +16,9 @@
|
||||
|
||||
ShaderResourceGroup MorphTargetPassSrg : SRG_PerPass
|
||||
{
|
||||
//Since we do Interlocked atomic operations on this buffer it can not be RWBuffer due to broken MetalSL generation.
|
||||
//It stems from the fact that typed buffers gets converted to textures and that breaks with atomic operations.
|
||||
//In future we can handle this under the hood via our metal shader pipeline
|
||||
RWStructuredBuffer<int> m_accumulatedDeltas;
|
||||
}
|
||||
|
||||
|
||||
+4
@@ -20,6 +20,10 @@
|
||||
ShaderResourceGroup PassSrg : SRG_PerPass
|
||||
{
|
||||
Texture2D<float4> m_inputTexture;
|
||||
|
||||
//Since we do Interlocked atomic operations on this buffer it can not be RWBuffer due to broken MetalSL generation.
|
||||
//It stems from the fact that typed buffers gets converted to textures and that breaks with atomic operations.
|
||||
//In future we can handle this under the hood via our metal shader pipeline
|
||||
RWStructuredBuffer<uint> m_outputTexture;
|
||||
}
|
||||
|
||||
|
||||
@@ -1360,6 +1360,16 @@ namespace AZ
|
||||
uint32_t ConvertColorWriteMask(uint8_t writeMask)
|
||||
{
|
||||
uint32_t dflags = 0;
|
||||
if(writeMask == 0)
|
||||
{
|
||||
return dflags;
|
||||
}
|
||||
|
||||
if(RHI::CheckBitsAll(writeMask, static_cast<uint8_t>(RHI::WriteChannelMask::ColorWriteMaskAll)))
|
||||
{
|
||||
return D3D12_COLOR_WRITE_ENABLE_ALL;
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAny(writeMask, static_cast<uint8_t>(RHI::WriteChannelMask::ColorWriteMaskRed)))
|
||||
{
|
||||
dflags |= D3D12_COLOR_WRITE_ENABLE_RED;
|
||||
|
||||
@@ -397,19 +397,18 @@ namespace AZ
|
||||
uint8_t numBitsSet = RHI::CountBitsSet(static_cast<uint64_t>(srgResourcesVisInfo.m_constantDataStageMask));
|
||||
if( numBitsSet > 0)
|
||||
{
|
||||
id<MTLResource> mtlconstantBufferResource = m_constantBuffer.GetGpuAddress<id<MTLResource>>();
|
||||
if(RHI::CheckBitsAny(srgResourcesVisInfo.m_constantDataStageMask, RHI::ShaderStageMask::Compute))
|
||||
{
|
||||
uint16_t arrayIndex = resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArrayLen;
|
||||
resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArray[arrayIndex] = m_constantBuffer.GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArrayLen++;
|
||||
uint16_t arrayIndex = resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArrayLen++;
|
||||
resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArray[arrayIndex] = mtlconstantBufferResource;
|
||||
}
|
||||
else
|
||||
{
|
||||
MTLRenderStages mtlRenderStages = GetRenderStages(srgResourcesVisInfo.m_constantDataStageMask);
|
||||
AZStd::pair <MTLResourceUsage,MTLRenderStages> key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages);
|
||||
uint16_t arrayIndex = resourcesToMakeResidentGraphics[key].m_resourceArrayLen;
|
||||
resourcesToMakeResidentGraphics[key].m_resourceArray[arrayIndex] = m_constantBuffer.GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentGraphics[key].m_resourceArrayLen++;
|
||||
uint16_t arrayIndex = resourcesToMakeResidentGraphics[key].m_resourceArrayLen++;
|
||||
resourcesToMakeResidentGraphics[key].m_resourceArray[arrayIndex] = mtlconstantBufferResource;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -431,7 +430,8 @@ namespace AZ
|
||||
}
|
||||
else
|
||||
{
|
||||
AZ_Assert(RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment), "The visibility mask %i is not set for Vertex or fragment stage", visMaskIt->second);
|
||||
bool isBoundToGraphics = RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment);
|
||||
AZ_Assert(isBoundToGraphics, "The visibility mask %i is not set for Vertex or fragment stage", visMaskIt->second);
|
||||
CollectResourcesForGraphics(commandEncoder, visMaskIt->second, it.second, resourcesToMakeResidentGraphics);
|
||||
}
|
||||
}
|
||||
@@ -480,9 +480,9 @@ namespace AZ
|
||||
AZ_Assert(false, "Undefined Resource type");
|
||||
}
|
||||
}
|
||||
uint16_t arrayIndex = resourcesToMakeResidentMap[resourceUsage].m_resourceArrayLen;
|
||||
resourcesToMakeResidentMap[resourceUsage].m_resourceArray[arrayIndex] = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentMap[resourceUsage].m_resourceArrayLen++;
|
||||
uint16_t arrayIndex = resourcesToMakeResidentMap[resourceUsage].m_resourceArrayLen++;
|
||||
id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentMap[resourceUsage].m_resourceArray[arrayIndex] = mtlResourceToBind;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -516,9 +516,9 @@ namespace AZ
|
||||
}
|
||||
|
||||
AZStd::pair <MTLResourceUsage, MTLRenderStages> key = AZStd::make_pair(resourceUsage, mtlRenderStages);
|
||||
uint16_t arrayIndex = resourcesToMakeResidentMap[key].m_resourceArrayLen;
|
||||
resourcesToMakeResidentMap[key].m_resourceArray[arrayIndex] = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentMap[key].m_resourceArrayLen++;
|
||||
uint16_t arrayIndex = resourcesToMakeResidentMap[key].m_resourceArrayLen++;
|
||||
id<MTLResource> mtlResourceToBind = resourceBindingData.m_resourcPtr->GetGpuAddress<id<MTLResource>>();
|
||||
resourcesToMakeResidentMap[key].m_resourceArray[arrayIndex] = mtlResourceToBind;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -126,12 +126,17 @@ namespace AZ
|
||||
uint16_t m_resourceArrayLen = 0;
|
||||
};
|
||||
//Map to cache all the resources based on the usage as we can batch all the resources for a given usage
|
||||
using ComputeResourcesToMakeResidentMap = AZStd::unordered_map<MTLResourceUsage, MetalResourceArray>;
|
||||
using ComputeResourcesToMakeResidentMap = AZStd::unordered_map<MTLResourceUsage, MetalResourceArray>;
|
||||
//Map to cache all the resources based on the usage and shader stage as we can batch all the resources for a given usage/shader usage
|
||||
using GraphicsResourcesToMakeResidentMap = AZStd::unordered_map<AZStd::pair<MTLResourceUsage,MTLRenderStages>, MetalResourceArray>;
|
||||
using GraphicsResourcesToMakeResidentMap = AZStd::unordered_map<AZStd::pair<MTLResourceUsage,MTLRenderStages>, MetalResourceArray>;
|
||||
|
||||
void CollectResourcesForCompute(id<MTLCommandEncoder> encoder, const ResourceBindingsSet& resourceBindingData, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const;
|
||||
void CollectResourcesForGraphics(id<MTLCommandEncoder> encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const;
|
||||
void CollectResourcesForCompute(id<MTLCommandEncoder> encoder,
|
||||
const ResourceBindingsSet& resourceBindingData,
|
||||
ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const;
|
||||
void CollectResourcesForGraphics(id<MTLCommandEncoder> encoder,
|
||||
RHI::ShaderStageMask visShaderMask,
|
||||
const ResourceBindingsSet& resourceBindingDataSet,
|
||||
GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const;
|
||||
//! Use visibility information to call UseResource on all resources for this Argument Buffer
|
||||
void ApplyUseResource(id<MTLCommandEncoder> encoder,
|
||||
const ResourceBindingsMap& resourceMap,
|
||||
|
||||
@@ -104,7 +104,11 @@ namespace AZ
|
||||
|
||||
using MetalArgumentBufferArray = AZStd::array<id<MTLBuffer>, RHI::Limits::Pipeline::ShaderResourceGroupCountMax>;
|
||||
using MetalArgumentBufferArrayOffsets = AZStd::array<NSUInteger, RHI::Limits::Pipeline::ShaderResourceGroupCountMax>;
|
||||
void BindArgumentBuffers(RHI::ShaderStage shaderStage, uint16_t registerIdMin, uint16_t registerIdMax, MetalArgumentBufferArray& mtlArgBuffers, MetalArgumentBufferArrayOffsets mtlArgBufferOffsets);
|
||||
void BindArgumentBuffers(RHI::ShaderStage shaderStage,
|
||||
uint16_t registerIdMin,
|
||||
uint16_t registerIdMax,
|
||||
MetalArgumentBufferArray& mtlArgBuffers,
|
||||
MetalArgumentBufferArrayOffsets mtlArgBufferOffsets);
|
||||
|
||||
ShaderResourceBindings& GetShaderResourceBindingsByPipelineType(RHI::PipelineStateType pipelineType);
|
||||
|
||||
|
||||
@@ -458,6 +458,16 @@ namespace AZ
|
||||
MTLColorWriteMask ConvertColorWriteMask(AZ::u8 writeMask)
|
||||
{
|
||||
MTLColorWriteMask colorMask = MTLColorWriteMaskNone;
|
||||
if(writeMask == 0)
|
||||
{
|
||||
return colorMask;
|
||||
}
|
||||
|
||||
if(RHI::CheckBitsAll(writeMask, static_cast<uint8_t>(RHI::WriteChannelMask::ColorWriteMaskAll)))
|
||||
{
|
||||
return MTLColorWriteMaskAll;
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAny(writeMask, static_cast<uint8_t>(RHI::WriteChannelMask::ColorWriteMaskRed)))
|
||||
{
|
||||
colorMask |= MTLColorWriteMaskRed;
|
||||
|
||||
@@ -334,6 +334,12 @@ namespace AZ
|
||||
VkColorComponentFlags ConvertComponentFlags(uint8_t sflags)
|
||||
{
|
||||
VkColorComponentFlags dflags = 0;
|
||||
|
||||
if(sflags == 0)
|
||||
{
|
||||
return dflags;
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAny(sflags, static_cast<uint8_t>(RHI::WriteChannelMask::ColorWriteMaskRed)))
|
||||
{
|
||||
dflags |= VK_COLOR_COMPONENT_R_BIT;
|
||||
|
||||
Reference in New Issue
Block a user