Skip to content

Commit

Permalink
Working on RTX vertex fetch
Browse files Browse the repository at this point in the history
  • Loading branch information
krupitskas committed Nov 23, 2024
1 parent 31f91fd commit 13dc79c
Show file tree
Hide file tree
Showing 8 changed files with 12 additions and 21 deletions.
2 changes: 1 addition & 1 deletion Shaders/ForwardPassPS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ struct PerInstanceData
{
float4x4 model_matrix;
int material_id;
int indices_count;
int vertices_before;
int indices_before;
int pad;
};
Expand Down
2 changes: 1 addition & 1 deletion Shaders/ForwardPassVS.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ struct PerInstanceData
{
float4x4 model_matrix;
int material_id;
int indices_count;
int vertices_before;
int indices_before;
int pad;
};
Expand Down
5 changes: 3 additions & 2 deletions Shaders/HitRT.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ struct PerInstanceData
{
float4x4 model_matrix;
int material_id;
int indices_count;
int vertices_before;
int indices_before;
int pad;
};
Expand Down Expand Up @@ -106,7 +106,8 @@ VertexData GetVertexData(uint geometry_id, uint triangle_index, float3 barycentr
// Interpolate the vertex attributes
//for (uint i = 0; i < 3; i++)
//{
// int address = (indices[i] * 12) * 4;
// //int address = (indices[i] * 12) * 4;
// int addess = VertexBuffer[geometry_id].vertices_before;
//
// // Load and interpolate position and transform it to world space
// triangle_vertices[i] = mul(ObjectToWorld3x4(), float4(asfloat(VertexBuffer[geometry_id].Load3(address)), 1.0f)).xyz;
Expand Down
2 changes: 1 addition & 1 deletion Shaders/RayGenRT.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ struct PerInstanceData
{
float4x4 model_matrix;
int material_id;
int indices_count;
int vertices_before;
int indices_before;
int pad;
};
Expand Down
2 changes: 1 addition & 1 deletion Yasno/Graphics/RenderScene.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ namespace ysn
{
DirectX::XMMATRIX model_matrix;
int32_t material_id;
int32_t indices_count;
int32_t vertices_before;
int32_t indices_before; // offset
int32_t pad;
};
Expand Down
2 changes: 0 additions & 2 deletions Yasno/Graphics/Techniques/RaytracingPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ namespace ysn
{4 /*t4*/, 1, 0, D3D12_DESCRIPTOR_RANGE_TYPE_SRV, 5}, // PerInstanceBuffer
{0 /*b0*/, 1, 0, D3D12_DESCRIPTOR_RANGE_TYPE_CBV /*Camera parameters*/, 6} });



return rsc.Generate(renderer->GetDevice().get(), true, m_static_samplers);
}

Expand Down
12 changes: 1 addition & 11 deletions Yasno/Renderer/nv_helpers_dx12/RootSignatureGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ namespace nv_helpers_dx12
// and pixel shaders. For raytracing shaders the root signatures are local.
rootDesc.Flags = isLocal ? D3D12_ROOT_SIGNATURE_FLAG_LOCAL_ROOT_SIGNATURE : D3D12_ROOT_SIGNATURE_FLAG_NONE;

// Setup single linear sampler to s0
D3D12_STATIC_SAMPLER_DESC static_sampler = {};
static_sampler.Filter = D3D12_FILTER_MIN_MAG_MIP_LINEAR;
static_sampler.AddressU = D3D12_TEXTURE_ADDRESS_MODE_WRAP;
Expand All @@ -193,17 +194,6 @@ namespace nv_helpers_dx12
rootDesc.NumStaticSamplers = 1;
rootDesc.pStaticSamplers = &static_sampler;

//if(!isLocal)
//{
// rootDesc.Flags |= D3D12_ROOT_SIGNATURE_FLAG_CBV_SRV_UAV_HEAP_DIRECTLY_INDEXED;
//}

//if(!samplers.empty())
//{
// rootDesc.NumStaticSamplers = samplers.size();
// rootDesc.pStaticSamplers = samplers.data();
//}

// Create the root signature from its descriptor
ID3DBlob* pSigBlob;
ID3DBlob* pErrorBlob;
Expand Down
6 changes: 4 additions & 2 deletions Yasno/Yasno/Yasno.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -437,6 +437,7 @@ namespace ysn
per_instance_data_buffer.reserve(m_render_scene.primitives_count);

uint32_t total_indices = 0;
uint32_t total_vertices = 0;

for (auto& model : m_render_scene.models)
{
Expand All @@ -459,10 +460,11 @@ namespace ysn
}

instance_data.model_matrix = model.transforms[mesh_id].transform;
instance_data.indices_count = primitive.index_count;
instance_data.vertices_before = total_vertices;
instance_data.indices_before = total_indices;

total_indices += instance_data.indices_count;
total_indices += primitive.index_count;
total_vertices += primitive.vertex_count;

per_instance_data_buffer.push_back(instance_data);
}
Expand Down

0 comments on commit 13dc79c

Please sign in to comment.