Merge pull request #1536 from aws-lumberyard-dev/Atom/dmcdiar/LYN-4660
[LYN-4660] Assigning test asset from AutomatedTest crashes in Atom
This commit is contained in:
+6
-6
@@ -151,15 +151,15 @@ ShaderResourceGroup RayTracingSceneSrg : SRG_RayTracingScene
|
||||
#define MESH_INDEX_BUFFER_OFFSET 0
|
||||
#define MESH_POSITION_BUFFER_OFFSET 1
|
||||
#define MESH_NORMAL_BUFFER_OFFSET 2
|
||||
#define MESH_TANGENT_BUFFER_OFFSET 3
|
||||
#define MESH_BITANGENT_BUFFER_OFFSET 4
|
||||
|
||||
// buffer flag bits indicating if optional buffers are present
|
||||
#define MESH_BUFFER_FLAG_UV 1
|
||||
// buffer flag bits indicating if optional buffers are present (note: these are bit masks)
|
||||
#define MESH_BUFFER_FLAG_TANGENT (1 << 0)
|
||||
#define MESH_BUFFER_FLAG_BITANGENT (1 << 1)
|
||||
#define MESH_BUFFER_FLAG_UV (1 << 2)
|
||||
|
||||
// Unbounded array of mesh stream buffers:
|
||||
// - Index, Position, Normal, Tangent, and Bitangent stream buffers are always present
|
||||
// - Optional stream buffers such as UV are indicated in the MeshInfo.m_bufferFlags field
|
||||
// - Index, Position, Normal stream buffers are always present
|
||||
// - Optional stream buffers such as Tangent, Bitangent, and UV are indicated in the MeshInfo.m_bufferFlags field
|
||||
// - Buffers for a particular mesh start at MeshInfo.m_bufferStartIndex
|
||||
ByteAddressBuffer m_meshBuffers[];
|
||||
}
|
||||
+15
-10
@@ -33,9 +33,9 @@ struct VertexData
|
||||
{
|
||||
float3 m_position;
|
||||
float3 m_normal;
|
||||
float3 m_tangent;
|
||||
float3 m_bitangent;
|
||||
float2 m_uv;
|
||||
float4 m_tangent; // optional: use only if MESH_BUFFER_FLAG_TANGENT in MeshData.m_bufferFlags is set
|
||||
float3 m_bitangent; // optional: use only if MESH_BUFFER_FLAG_BITANGENT in MeshData.m_bufferFlags is set
|
||||
float2 m_uv; // optional: use only if MESH_BUFFER_FLAG_UV in MeshData.m_bufferFlags is set
|
||||
};
|
||||
|
||||
VertexData GetHitInterpolatedVertexData(RayTracingSceneSrg::MeshInfo meshInfo, float2 builtInBarycentrics)
|
||||
@@ -74,22 +74,27 @@ VertexData GetHitInterpolatedVertexData(RayTracingSceneSrg::MeshInfo meshInfo, f
|
||||
vertexData.m_normal += asfloat(RayTracingSceneSrg::m_meshBuffers[meshVertexNormalArrayIndex].Load3(normalOffset)) * barycentrics[i];
|
||||
}
|
||||
|
||||
// optional streams begin after MESH_NORMAL_BUFFER_OFFSET
|
||||
uint optionalBufferOffset = MESH_NORMAL_BUFFER_OFFSET + 1;
|
||||
|
||||
// tangent
|
||||
if (meshInfo.m_bufferFlags & MESH_BUFFER_FLAG_TANGENT)
|
||||
{
|
||||
// array index of the tangent buffer for this mesh in the m_meshBuffers unbounded array
|
||||
uint meshVertexTangentArrayIndex = meshInfo.m_bufferStartIndex + MESH_TANGENT_BUFFER_OFFSET;
|
||||
uint meshVertexTangentArrayIndex = meshInfo.m_bufferStartIndex + optionalBufferOffset++;
|
||||
|
||||
// offset into the tangent buffer for this vertex
|
||||
uint tangentOffset = meshInfo.m_tangentOffset + (indices[i] * 12);
|
||||
uint tangentOffset = meshInfo.m_tangentOffset + (indices[i] * 16);
|
||||
|
||||
// load the tangent data
|
||||
vertexData.m_tangent += asfloat(RayTracingSceneSrg::m_meshBuffers[meshVertexTangentArrayIndex].Load3(tangentOffset)) * barycentrics[i];
|
||||
vertexData.m_tangent += asfloat(RayTracingSceneSrg::m_meshBuffers[meshVertexTangentArrayIndex].Load4(tangentOffset)) * barycentrics[i];
|
||||
}
|
||||
|
||||
// bitangent
|
||||
if (meshInfo.m_bufferFlags & MESH_BUFFER_FLAG_BITANGENT)
|
||||
{
|
||||
// array index of the bitangent buffer for this mesh in the m_meshBuffers unbounded array
|
||||
uint meshVertexBitangentArrayIndex = meshInfo.m_bufferStartIndex + MESH_BITANGENT_BUFFER_OFFSET;
|
||||
uint meshVertexBitangentArrayIndex = meshInfo.m_bufferStartIndex + optionalBufferOffset++;
|
||||
|
||||
// offset into the bitangent buffer for this vertex
|
||||
uint bitangentOffset = meshInfo.m_bitangentOffset + (indices[i] * 12);
|
||||
@@ -98,9 +103,6 @@ VertexData GetHitInterpolatedVertexData(RayTracingSceneSrg::MeshInfo meshInfo, f
|
||||
vertexData.m_bitangent += asfloat(RayTracingSceneSrg::m_meshBuffers[meshVertexBitangentArrayIndex].Load3(bitangentOffset)) * barycentrics[i];
|
||||
}
|
||||
|
||||
// optional streams begin after MESH_BITANGENT_BUFFER_OFFSET
|
||||
uint optionalBufferOffset = MESH_BITANGENT_BUFFER_OFFSET + 1;
|
||||
|
||||
// UV
|
||||
if (meshInfo.m_bufferFlags & MESH_BUFFER_FLAG_UV)
|
||||
{
|
||||
@@ -116,6 +118,9 @@ VertexData GetHitInterpolatedVertexData(RayTracingSceneSrg::MeshInfo meshInfo, f
|
||||
}
|
||||
|
||||
vertexData.m_normal = normalize(vertexData.m_normal);
|
||||
vertexData.m_tangent.xyz = normalize(vertexData.m_tangent.xyz);
|
||||
vertexData.m_tangent.w = sign(vertexData.m_tangent.w);
|
||||
vertexData.m_bitangent = normalize(vertexData.m_bitangent);
|
||||
|
||||
return vertexData;
|
||||
}
|
||||
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
BIN
Binary file not shown.
@@ -706,7 +706,7 @@ namespace AZ
|
||||
static const char* UVSemantic = "UV";
|
||||
static const RHI::Format PositionStreamFormat = RHI::Format::R32G32B32_FLOAT;
|
||||
static const RHI::Format NormalStreamFormat = RHI::Format::R32G32B32_FLOAT;
|
||||
static const RHI::Format TangentStreamFormat = RHI::Format::R32G32B32_FLOAT;
|
||||
static const RHI::Format TangentStreamFormat = RHI::Format::R32G32B32A32_FLOAT;
|
||||
static const RHI::Format BitangentStreamFormat = RHI::Format::R32G32B32_FLOAT;
|
||||
static const RHI::Format UVStreamFormat = RHI::Format::R32G32_FLOAT;
|
||||
|
||||
@@ -729,10 +729,12 @@ namespace AZ
|
||||
RPI::ShaderInputContract::StreamChannelInfo tangentStreamChannelInfo;
|
||||
tangentStreamChannelInfo.m_semantic = RHI::ShaderSemantic(AZ::Name(TangentSemantic));
|
||||
tangentStreamChannelInfo.m_componentCount = RHI::GetFormatComponentCount(TangentStreamFormat);
|
||||
tangentStreamChannelInfo.m_isOptional = true;
|
||||
|
||||
RPI::ShaderInputContract::StreamChannelInfo bitangentStreamChannelInfo;
|
||||
bitangentStreamChannelInfo.m_semantic = RHI::ShaderSemantic(AZ::Name(BitangentSemantic));
|
||||
bitangentStreamChannelInfo.m_componentCount = RHI::GetFormatComponentCount(BitangentStreamFormat);
|
||||
bitangentStreamChannelInfo.m_isOptional = true;
|
||||
|
||||
RPI::ShaderInputContract::StreamChannelInfo uvStreamChannelInfo;
|
||||
uvStreamChannelInfo.m_semantic = RHI::ShaderSemantic(AZ::Name(UVSemantic));
|
||||
@@ -818,13 +820,21 @@ namespace AZ
|
||||
subMesh.m_normalVertexBufferView = streamBufferViews[1];
|
||||
subMesh.m_normalShaderBufferView = const_cast<RHI::Buffer*>(streamBufferViews[1].GetBuffer())->GetBufferView(normalBufferDescriptor);
|
||||
|
||||
subMesh.m_tangentFormat = TangentStreamFormat;
|
||||
subMesh.m_tangentVertexBufferView = streamBufferViews[2];
|
||||
subMesh.m_tangentShaderBufferView = const_cast<RHI::Buffer*>(streamBufferViews[2].GetBuffer())->GetBufferView(tangentBufferDescriptor);
|
||||
if (tangentBufferByteCount > 0)
|
||||
{
|
||||
subMesh.m_bufferFlags |= RayTracingSubMeshBufferFlags::Tangent;
|
||||
subMesh.m_tangentFormat = TangentStreamFormat;
|
||||
subMesh.m_tangentVertexBufferView = streamBufferViews[2];
|
||||
subMesh.m_tangentShaderBufferView = const_cast<RHI::Buffer*>(streamBufferViews[2].GetBuffer())->GetBufferView(tangentBufferDescriptor);
|
||||
}
|
||||
|
||||
subMesh.m_bitangentFormat = BitangentStreamFormat;
|
||||
subMesh.m_bitangentVertexBufferView = streamBufferViews[3];
|
||||
subMesh.m_bitangentShaderBufferView = const_cast<RHI::Buffer*>(streamBufferViews[3].GetBuffer())->GetBufferView(bitangentBufferDescriptor);
|
||||
if (bitangentBufferByteCount > 0)
|
||||
{
|
||||
subMesh.m_bufferFlags |= RayTracingSubMeshBufferFlags::Bitangent;
|
||||
subMesh.m_bitangentFormat = BitangentStreamFormat;
|
||||
subMesh.m_bitangentVertexBufferView = streamBufferViews[3];
|
||||
subMesh.m_bitangentShaderBufferView = const_cast<RHI::Buffer*>(streamBufferViews[3].GetBuffer())->GetBufferView(bitangentBufferDescriptor);
|
||||
}
|
||||
|
||||
if (uvBufferByteCount > 0)
|
||||
{
|
||||
|
||||
@@ -238,8 +238,16 @@ namespace AZ
|
||||
meshInfo.m_indexOffset = subMesh.m_indexBufferView.GetByteOffset();
|
||||
meshInfo.m_positionOffset = subMesh.m_positionVertexBufferView.GetByteOffset();
|
||||
meshInfo.m_normalOffset = subMesh.m_normalVertexBufferView.GetByteOffset();
|
||||
meshInfo.m_tangentOffset = subMesh.m_tangentVertexBufferView.GetByteOffset();
|
||||
meshInfo.m_bitangentOffset = subMesh.m_bitangentVertexBufferView.GetByteOffset();
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::Tangent))
|
||||
{
|
||||
meshInfo.m_tangentOffset = subMesh.m_tangentVertexBufferView.GetByteOffset();
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::Bitangent))
|
||||
{
|
||||
meshInfo.m_bitangentOffset = subMesh.m_bitangentVertexBufferView.GetByteOffset();
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::UV))
|
||||
{
|
||||
@@ -252,8 +260,8 @@ namespace AZ
|
||||
meshInfo.m_bufferStartIndex = bufferStartIndex;
|
||||
|
||||
// add the count of buffers present in this subMesh to the start index for the next subMesh
|
||||
// note that the Index, Position, Normal, Tangent, and Bitangent buffers are always counted since they are guaranteed
|
||||
static const uint32_t RayTracingSubMeshFixedStreamCount = 5;
|
||||
// note that the Index, Position, and Normal buffers are always counted since they are guaranteed
|
||||
static const uint32_t RayTracingSubMeshFixedStreamCount = 3;
|
||||
bufferStartIndex += (RayTracingSubMeshFixedStreamCount + RHI::CountBitsSet(aznumeric_cast<uint32_t>(meshInfo.m_bufferFlags)));
|
||||
|
||||
meshInfos.emplace_back(meshInfo);
|
||||
@@ -418,8 +426,16 @@ namespace AZ
|
||||
meshBuffers.push_back(subMesh.m_indexShaderBufferView.get());
|
||||
meshBuffers.push_back(subMesh.m_positionShaderBufferView.get());
|
||||
meshBuffers.push_back(subMesh.m_normalShaderBufferView.get());
|
||||
meshBuffers.push_back(subMesh.m_tangentShaderBufferView.get());
|
||||
meshBuffers.push_back(subMesh.m_bitangentShaderBufferView.get());
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::Tangent))
|
||||
{
|
||||
meshBuffers.push_back(subMesh.m_tangentShaderBufferView.get());
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::Bitangent))
|
||||
{
|
||||
meshBuffers.push_back(subMesh.m_bitangentShaderBufferView.get());
|
||||
}
|
||||
|
||||
if (RHI::CheckBitsAll(subMesh.m_bufferFlags, RayTracingSubMeshBufferFlags::UV))
|
||||
{
|
||||
|
||||
@@ -27,7 +27,9 @@ namespace AZ
|
||||
{
|
||||
None = 0,
|
||||
|
||||
UV = AZ_BIT(0)
|
||||
Tangent = AZ_BIT(0),
|
||||
Bitangent = AZ_BIT(1),
|
||||
UV = AZ_BIT(2)
|
||||
};
|
||||
AZ_DEFINE_ENUM_BITWISE_OPERATORS(AZ::Render::RayTracingSubMeshBufferFlags);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user