Add access to vertex indices in frag_raytrace.glsl

This commit is contained in:
RaveYard 2023-09-20 16:06:48 +02:00 committed by Christoph Oelckers
parent ef065fb9b9
commit 29b8fcf6c8
4 changed files with 15 additions and 14 deletions

View file

@ -486,6 +486,7 @@ void VkLightmap::CreateRaytracePipeline()
raytrace.descriptorSetLayout1 = DescriptorSetLayoutBuilder()
.AddBinding(0, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 1, VK_SHADER_STAGE_FRAGMENT_BIT)
.AddBinding(1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT)
.AddBinding(2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, 1, VK_SHADER_STAGE_FRAGMENT_BIT)
.DebugName("raytrace.descriptorSetLayout1")
.Create(fb->GetDevice());
}
@ -579,6 +580,7 @@ void VkLightmap::UpdateAccelStructDescriptors()
WriteDescriptors()
.AddAccelerationStructure(raytrace.descriptorSet1.get(), 0, fb->GetRaytrace()->GetAccelStruct())
.AddBuffer(raytrace.descriptorSet1.get(), 1, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetVertexBuffer())
.AddBuffer(raytrace.descriptorSet1.get(), 2, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, fb->GetRaytrace()->GetIndexBuffer())
.Execute(fb->GetDevice());
}
else

View file

@ -193,15 +193,15 @@ void VkRaytrace::CreateBuffers()
.AddBuffer(surfaceBuffer.get(), surfaceInfo.Data(), surfaceInfo.Size() * sizeof(SurfaceInfo))
.AddBuffer(portalBuffer.get(), portalInfo.Data(), portalInfo.Size() * sizeof(PortalInfo))
.Execute(fb->GetDevice(), fb->GetCommands()->GetTransferCommands());
PipelineBarrier()
.AddMemory(VK_ACCESS_TRANSFER_WRITE_BIT, useRayQuery ? VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR : VK_ACCESS_SHADER_READ_BIT)
.Execute(fb->GetCommands()->GetTransferCommands(), VK_PIPELINE_STAGE_TRANSFER_BIT, useRayQuery ? VK_PIPELINE_STAGE_ACCELERATION_STRUCTURE_BUILD_BIT_KHR : VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
if(useRayQuery)
/*if (useRayQuery)
PipelineBarrier()
.AddMemory(VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT)
.Execute(fb->GetCommands()->GetTransferCommands(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);
.Execute(fb->GetCommands()->GetTransferCommands(), VK_PIPELINE_STAGE_TRANSFER_BIT, VK_PIPELINE_STAGE_FRAGMENT_SHADER_BIT);*/
}
void VkRaytrace::CreateBottomLevelAccelerationStructure()

View file

@ -1512,16 +1512,17 @@ void DoomLevelMesh::CreateSurfaceTextureUVs(FLevelLocals& doomMap)
if (surface.Type == ST_FLOOR || surface.Type == ST_CEILING)
{
for (int i = 0; i < surface.numVerts; ++i)
{
uvs[surface.atlasPageIndex + 0] = verts[0].XY() * (1.0f / 64.0f);
}
}
else
{
for (int i = 0; i < 4; ++i)
{
uvs[surface.atlasPageIndex + i] = verts[i] - verts[0];
uvs[surface.atlasPageIndex + i].X /= gtxt->GetDisplayWidth();
uvs[surface.atlasPageIndex + i].Y /= gtxt->GetDisplayHeight();
}
uvs[surface.atlasPageIndex + 0] = FVector2(0, 1); //toUv(&surface, verts[0] - verts[0]);
uvs[surface.atlasPageIndex + 1] = FVector2(1, 1); //toUv(&surface, verts[0] - verts[0]);
uvs[surface.atlasPageIndex + 2] = FVector2(0, 0); //toUv(&surface, verts[0] - verts[0]);
uvs[surface.atlasPageIndex + 3] = FVector2(1, 0); //toUv(&surface, verts[0] - verts[0]);
}
}
}

View file

@ -31,11 +31,7 @@ struct SurfaceVertex
};
layout(std430, set = 1, binding = 1) buffer VertexBuffer { SurfaceVertex vertices[]; };
#if defined(USE_RAYQUERY)
#else
layout(std430, set = 1, binding = 2) buffer ElementBuffer { int elements[]; };
#endif
layout(set = 0, binding = 0) uniform Uniforms
{
@ -260,6 +256,8 @@ int TraceFirstHitTriangleNoPortal(vec3 origin, float tmin, vec3 dir, float tmax,
primitiveWeights.xy = rayQueryGetIntersectionBarycentricsEXT(rayQuery, true);
primitiveWeights.z = 1.0 - primitiveWeights.x - primitiveWeights.y;
primitiveWeights = vec3(primitiveWeights.z, primitiveWeights.x, primitiveWeights.y);
return rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true);
}
else