Skip to content

Commit 30a5a19

Browse files
author
kevyuu
committed
Remore normal type unknown from demo
1 parent 25f1cd4 commit 30a5a19

File tree

6 files changed

+10
-32
lines changed

6 files changed

+10
-32
lines changed

67_RayQueryGeometry/app_resources/common.hlsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ enum NormalType : uint32_t
99
{
1010
NT_R8G8B8A8_SNORM,
1111
NT_R32G32B32_SFLOAT,
12-
NT_UNKNOWN
1312
};
1413

1514
// we need bitfield support in NBL_HLSL_DECLARE_STRUCT it seems
@@ -19,7 +18,7 @@ struct SGeomInfo
1918
uint64_t indexBufferAddress;
2019
uint64_t normalBufferAddress;
2120

22-
uint32_t normalType : 2;
21+
uint32_t normalType : 1;
2322
uint32_t indexType : 1; // 16 bit, 32 bit
2423
};
2524

67_RayQueryGeometry/app_resources/render.comp.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ float3 calculateNormals(int primID, SGeomInfo geom, float2 bary)
5353
}
5454
}
5555

56-
if (normalBufferAddress == 0 || normalType == NT_UNKNOWN)
56+
if (normalBufferAddress == 0)
5757
{
5858
float3 v0 = vk::RawBufferLoad<float3>(vertexBufferAddress + indices[0] * 12);
5959
float3 v1 = vk::RawBufferLoad<float3>(vertexBufferAddress + indices[1] * 12);

67_RayQueryGeometry/main.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -847,19 +847,9 @@ class RayQueryGeometryApp final : public SimpleWindowedApplication, public Built
847847
const auto& normalView = gpuPolygon->getNormalView();
848848
const uint64_t normalBufferAddress = normalView ? normalView.src.buffer->getDeviceAddress() + normalView.src.offset : 0;
849849

850-
const auto normalType = [&normalView]
851-
{
852-
if (!normalView) return NT_UNKNOWN;
853-
switch (normalView.composed.format)
854-
{
855-
case EF_R32G32B32_SFLOAT:
856-
return NT_R32G32B32_SFLOAT;
857-
case EF_R8G8B8A8_SNORM:
858-
return NT_R8G8B8A8_SNORM;
859-
default:
860-
return NT_UNKNOWN;
861-
}
862-
}();
850+
auto normalType = NT_R32G32B32_SFLOAT;
851+
if (normalView && normalView.composed.format == EF_R8G8B8A8_SNORM)
852+
normalType = NT_R8G8B8A8_SNORM;
863853

864854
const auto& indexBufferBinding = gpuTriangles.indexData;
865855
auto& geomInfo = geomInfos[i];

71_RayTracingPipeline/app_resources/common.hlsl

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ enum NormalType : uint32_t
9090
{
9191
NT_R8G8B8A8_SNORM,
9292
NT_R32G32B32_SFLOAT,
93-
NT_UNKNOWN
9493
};
9594

9695
struct STriangleGeomInfo
@@ -100,7 +99,7 @@ struct STriangleGeomInfo
10099
uint64_t indexBufferAddress;
101100
uint64_t normalBufferAddress;
102101

103-
uint32_t normalType : 2;
102+
uint32_t normalType : 1;
104103
uint32_t indexType : 1; // 16 bit, 32 bit
105104

106105
};

71_RayTracingPipeline/app_resources/raytrace.rchit.hlsl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ float3 calculateNormals(int primID, STriangleGeomInfo geom, float2 bary)
3232
}
3333
}
3434

35-
if (normalBufferAddress == 0 || normalType == NT_UNKNOWN)
35+
if (normalBufferAddress == 0)
3636
{
3737
float3 v0 = vk::RawBufferLoad<float3>(vertexBufferAddress + indices[0] * 12);
3838
float3 v1 = vk::RawBufferLoad<float3>(vertexBufferAddress + indices[1] * 12);

71_RayTracingPipeline/main.cpp

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1444,19 +1444,9 @@ class RaytracingPipelineApp final : public SimpleWindowedApplication, public Bui
14441444

14451445
const auto& normalView = gpuPolygon->getNormalView();
14461446
const uint64_t normalBufferAddress = normalView ? normalView.src.buffer->getDeviceAddress() + normalView.src.offset : 0;
1447-
const auto normalType = [&normalView]
1448-
{
1449-
if (!normalView) return NT_UNKNOWN;
1450-
switch (normalView.composed.format)
1451-
{
1452-
case EF_R32G32B32_SFLOAT:
1453-
return NT_R32G32B32_SFLOAT;
1454-
case EF_R8G8B8A8_SNORM:
1455-
return NT_R8G8B8A8_SNORM;
1456-
default:
1457-
return NT_UNKNOWN;
1458-
}
1459-
}();
1447+
auto normalType = NT_R32G32B32_SFLOAT;
1448+
if (normalView && normalView.composed.format == EF_R8G8B8A8_SNORM)
1449+
normalType = NT_R8G8B8A8_SNORM;
14601450

14611451
const auto& indexBufferBinding = gpuTriangles.indexData;
14621452
auto& geomInfo = geomInfos[i];

0 commit comments

Comments
 (0)