mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
Add access to vertex indices in frag_raytrace.glsl
This commit is contained in:
parent
ef065fb9b9
commit
29b8fcf6c8
4 changed files with 15 additions and 14 deletions
|
@ -486,6 +486,7 @@ void VkLightmap::CreateRaytracePipeline()
|
||||||
raytrace.descriptorSetLayout1 = DescriptorSetLayoutBuilder()
|
raytrace.descriptorSetLayout1 = DescriptorSetLayoutBuilder()
|
||||||
.AddBinding(0, VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, 1, VK_SHADER_STAGE_FRAGMENT_BIT)
|
.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(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")
|
.DebugName("raytrace.descriptorSetLayout1")
|
||||||
.Create(fb->GetDevice());
|
.Create(fb->GetDevice());
|
||||||
}
|
}
|
||||||
|
@ -579,6 +580,7 @@ void VkLightmap::UpdateAccelStructDescriptors()
|
||||||
WriteDescriptors()
|
WriteDescriptors()
|
||||||
.AddAccelerationStructure(raytrace.descriptorSet1.get(), 0, fb->GetRaytrace()->GetAccelStruct())
|
.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(), 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());
|
.Execute(fb->GetDevice());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
|
@ -198,10 +198,10 @@ void VkRaytrace::CreateBuffers()
|
||||||
.AddMemory(VK_ACCESS_TRANSFER_WRITE_BIT, useRayQuery ? VK_ACCESS_ACCELERATION_STRUCTURE_READ_BIT_KHR : VK_ACCESS_SHADER_READ_BIT)
|
.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);
|
.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()
|
PipelineBarrier()
|
||||||
.AddMemory(VK_ACCESS_TRANSFER_WRITE_BIT, VK_ACCESS_SHADER_READ_BIT)
|
.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()
|
void VkRaytrace::CreateBottomLevelAccelerationStructure()
|
||||||
|
|
|
@ -1512,16 +1512,17 @@ void DoomLevelMesh::CreateSurfaceTextureUVs(FLevelLocals& doomMap)
|
||||||
|
|
||||||
if (surface.Type == ST_FLOOR || surface.Type == ST_CEILING)
|
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
|
else
|
||||||
{
|
{
|
||||||
for (int i = 0; i < 4; ++i)
|
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 + i] = verts[i] - 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]);
|
||||||
uvs[surface.atlasPageIndex + i].X /= gtxt->GetDisplayWidth();
|
|
||||||
uvs[surface.atlasPageIndex + i].Y /= gtxt->GetDisplayHeight();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,11 +31,7 @@ struct SurfaceVertex
|
||||||
};
|
};
|
||||||
|
|
||||||
layout(std430, set = 1, binding = 1) buffer VertexBuffer { SurfaceVertex vertices[]; };
|
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[]; };
|
layout(std430, set = 1, binding = 2) buffer ElementBuffer { int elements[]; };
|
||||||
#endif
|
|
||||||
|
|
||||||
layout(set = 0, binding = 0) uniform Uniforms
|
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.xy = rayQueryGetIntersectionBarycentricsEXT(rayQuery, true);
|
||||||
primitiveWeights.z = 1.0 - primitiveWeights.x - primitiveWeights.y;
|
primitiveWeights.z = 1.0 - primitiveWeights.x - primitiveWeights.y;
|
||||||
|
|
||||||
|
primitiveWeights = vec3(primitiveWeights.z, primitiveWeights.x, primitiveWeights.y);
|
||||||
|
|
||||||
return rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true);
|
return rayQueryGetIntersectionPrimitiveIndexEXT(rayQuery, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Reference in a new issue