diff --git a/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp b/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp index 3555226bc2..ba24a5e1dd 100644 --- a/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp +++ b/src/common/rendering/vulkan/accelstructs/vk_lightmap.cpp @@ -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 diff --git a/src/common/rendering/vulkan/accelstructs/vk_raytrace.cpp b/src/common/rendering/vulkan/accelstructs/vk_raytrace.cpp index 611483ad52..7b5b14b5b8 100644 --- a/src/common/rendering/vulkan/accelstructs/vk_raytrace.cpp +++ b/src/common/rendering/vulkan/accelstructs/vk_raytrace.cpp @@ -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() diff --git a/src/rendering/hwrenderer/doom_levelmesh.cpp b/src/rendering/hwrenderer/doom_levelmesh.cpp index b7fe81a027..e52f3bf356 100644 --- a/src/rendering/hwrenderer/doom_levelmesh.cpp +++ b/src/rendering/hwrenderer/doom_levelmesh.cpp @@ -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]); } } } diff --git a/wadsrc/static/shaders/lightmap/frag_raytrace.glsl b/wadsrc/static/shaders/lightmap/frag_raytrace.glsl index 5381490764..b15b3f2ee2 100644 --- a/wadsrc/static/shaders/lightmap/frag_raytrace.glsl +++ b/wadsrc/static/shaders/lightmap/frag_raytrace.glsl @@ -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