diff --git a/renderdoc/data/glsl/debuguniforms.h b/renderdoc/data/glsl/debuguniforms.h index 38c9753c3..345e4fb7c 100644 --- a/renderdoc/data/glsl/debuguniforms.h +++ b/renderdoc/data/glsl/debuguniforms.h @@ -130,12 +130,6 @@ BINDING(0) uniform FontUBOData } INST_NAME(general); -#define MESH_OTHER 0 // this covers points and lines, logic is the same -#define MESH_TRIANGLE_LIST 1 -#define MESH_TRIANGLE_STRIP 2 -#define MESH_TRIANGLE_FAN 3 -#define MESH_TRIANGLE_LIST_ADJ 4 -#define MESH_TRIANGLE_STRIP_ADJ 5 BINDING(0) uniform MeshPickUBOData { vec3 rayPos; @@ -266,3 +260,10 @@ INST_NAME(texdisplay); #define HGRAM_TILES_PER_BLOCK 10u #define HGRAM_NUM_BUCKETS 256u + +#define MESH_OTHER 0 // this covers points and lines, logic is the same +#define MESH_TRIANGLE_LIST 1 +#define MESH_TRIANGLE_STRIP 2 +#define MESH_TRIANGLE_FAN 3 +#define MESH_TRIANGLE_LIST_ADJ 4 +#define MESH_TRIANGLE_STRIP_ADJ 5 \ No newline at end of file diff --git a/renderdoc/data/glsl/mesh.comp b/renderdoc/data/glsl/mesh.comp index c23578d5e..c9790c604 100644 --- a/renderdoc/data/glsl/mesh.comp +++ b/renderdoc/data/glsl/mesh.comp @@ -1,18 +1,18 @@ /****************************************************************************** * The MIT License (MIT) - * + * * Copyright (c) 2016 Baldur Karlsson - * + * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software"), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE @@ -40,7 +40,7 @@ layout(binding = 3, std140) buffer pickresult_buffer layout (local_size_x = 128, local_size_y = 1, local_size_z = 1) in; -bool TriangleRayIntersect(vec3 A, vec3 B, vec3 C, +bool TriangleRayIntersect(vec3 A, vec3 B, vec3 C, vec3 RayPosition, vec3 RayDirection, out vec3 HitPosition) { bool Result = false; @@ -80,7 +80,7 @@ bool TriangleRayIntersect(vec3 A, vec3 B, vec3 C, void trianglePath(uint threadID) { uint vertid = uint(mod(float(threadID), float(meshpick.numVerts))); - + uint vertid0 = 0; uint vertid1 = 0; uint vertid2 = 0; @@ -132,20 +132,20 @@ void trianglePath(uint threadID) #ifdef VULKAN if(meshpick.unproject == 1u) - { - pos0 = vec4(pos0.x, -pos0.y, pos0.z, pos0.w); - pos1 = vec4(pos1.x, -pos1.y, pos1.z, pos1.w); - pos2 = vec4(pos2.x, -pos2.y, pos2.z, pos2.w); - } + { + pos0 = vec4(pos0.x, -pos0.y, pos0.z, pos0.w); + pos1 = vec4(pos1.x, -pos1.y, pos1.z, pos1.w); + pos2 = vec4(pos2.x, -pos2.y, pos2.z, pos2.w); + } #endif vec3 hitPosition; - bool hit = TriangleRayIntersect(pos0.xyz/pos0.w, pos1.xyz/pos1.w, pos2.xyz/pos2.w, - meshpick.rayPos, meshpick.rayDir, + bool hit = TriangleRayIntersect(pos0.xyz/pos0.w, pos1.xyz/pos1.w, pos2.xyz/pos2.w, + meshpick.rayPos, meshpick.rayDir, /*out*/ hitPosition); - - // ray hit a triangle, so return the vertex that was closest - // to the triangle/ray intersection point + + // ray hit a triangle, so return the vertex that was closest + // to the triangle/ray intersection point if (hit) { float dist0 = distance(pos0.xyz/pos0.w, hitPosition); @@ -163,8 +163,8 @@ void trianglePath(uint threadID) { meshVert = vertid2; } - pickresult.results[result_idx] = uvec4(meshVert, - floatBitsToUint(hitPosition.x), floatBitsToUint(hitPosition.y), floatBitsToUint(hitPosition.z)); + pickresult.results[result_idx] = uvec4(meshVert, + floatBitsToUint(hitPosition.x), floatBitsToUint(hitPosition.y), floatBitsToUint(hitPosition.z)); } } @@ -204,7 +204,6 @@ void defaultPath(uint threadID) void main() { - if (meshpick.meshMode == MESH_OTHER) { defaultPath(gl_GlobalInvocationID.x); diff --git a/renderdoc/data/hlsl/debugcbuffers.h b/renderdoc/data/hlsl/debugcbuffers.h index 2036d599c..177f2dda2 100644 --- a/renderdoc/data/hlsl/debugcbuffers.h +++ b/renderdoc/data/hlsl/debugcbuffers.h @@ -156,3 +156,9 @@ cbuffer HistogramCBufferData REG(b0) #define HGRAM_TILES_PER_BLOCK 32 #define HGRAM_NUM_BUCKETS 256 + +#define MESH_OTHER 0 // this covers points and lines, logic is the same +#define MESH_TRIANGLE_LIST 1 +#define MESH_TRIANGLE_STRIP 2 +#define MESH_TRIANGLE_LIST_ADJ 3 +#define MESH_TRIANGLE_STRIP_ADJ 4 \ No newline at end of file diff --git a/renderdoc/data/hlsl/mesh.hlsl b/renderdoc/data/hlsl/mesh.hlsl index 5172198ad..577a61d4b 100644 --- a/renderdoc/data/hlsl/mesh.hlsl +++ b/renderdoc/data/hlsl/mesh.hlsl @@ -68,20 +68,20 @@ wireframeV2F RENDERDOC_MeshVS(meshA2V IN, uint vid : SV_VertexID) [maxvertexcount(3)] void RENDERDOC_MeshGS(triangle wireframeV2F input[3], inout TriangleStream TriStream) { - wireframeV2F output; + wireframeV2F output; - float4 faceEdgeA = mul(input[1].pos, InvProj) - mul(input[0].pos, InvProj); - float4 faceEdgeB = mul(input[2].pos, InvProj) - mul(input[0].pos, InvProj); - float3 faceNormal = normalize( cross(faceEdgeA.xyz, faceEdgeB.xyz) ); + float4 faceEdgeA = mul(input[1].pos, InvProj) - mul(input[0].pos, InvProj); + float4 faceEdgeB = mul(input[2].pos, InvProj) - mul(input[0].pos, InvProj); + float3 faceNormal = normalize( cross(faceEdgeA.xyz, faceEdgeB.xyz) ); - for(int i=0; i<3; i++) - { - output.pos = input[i].pos; - output.norm = faceNormal; - output.secondary = input[i].secondary; - TriStream.Append(output); - } - TriStream.RestartStrip(); + for(int i=0; i<3; i++) + { + output.pos = input[i].pos; + output.norm = faceNormal; + output.secondary = input[i].secondary; + TriStream.Append(output); + } + TriStream.RestartStrip(); } float4 RENDERDOC_MeshPS(wireframeV2F IN) : SV_Target0 @@ -124,9 +124,8 @@ wireframeV2F RENDERDOC_WireframeVS(float3 pos : POSITION, uint vid : SV_VertexID #define MESH_OTHER 0 // this covers points and lines, logic is the same #define MESH_TRIANGLE_LIST 1 #define MESH_TRIANGLE_STRIP 2 -#define MESH_TRIANGLE_FAN 3 -#define MESH_TRIANGLE_LIST_ADJ 4 -#define MESH_TRIANGLE_STRIP_ADJ 5 +#define MESH_TRIANGLE_LIST_ADJ 3 +#define MESH_TRIANGLE_STRIP_ADJ 4 Buffer index : register(t0); Buffer vertex : register(t1); @@ -134,17 +133,17 @@ AppendStructuredBuffer pickresult : register(u0); cbuffer MeshPickData : register(b0) { - float3 PickRayPos; - uint PickIdx; + float3 PickRayPos; + uint PickIdx; - float3 PickRayDir; - uint PickNumVerts; + float3 PickRayDir; + uint PickNumVerts; float2 PickCoords; float2 PickViewport; - uint PickMeshMode; - float3 Padding; + uint PickMeshMode; + float3 Padding; row_major float4x4 PickMVP; }; @@ -212,13 +211,6 @@ void trianglePath(uint threadID) vertid2 = vertid+2; break; } - case MESH_TRIANGLE_FAN: - { - vertid0 = 0; - vertid1 = vertid+1; - vertid2 = vertid+2; - break; - } case MESH_TRIANGLE_LIST_ADJ: { vertid *= 6; @@ -246,8 +238,8 @@ void trianglePath(uint threadID) PickRayPos, PickRayDir, /*out*/ hitPosition); - // ray hit a triangle, so return the vertex that was closest - // to the triangle/ray intersection point + // ray hit a triangle, so return the vertex that was closest + // to the triangle/ray intersection point if (hit) { float dist0 = distance(pos0.xyz/pos0.w, hitPosition); @@ -263,8 +255,8 @@ void trianglePath(uint threadID) { meshVert = vertid2; } - pickresult.Append(uint4(meshVert, - asuint(hitPosition.x), asuint(hitPosition.y), asuint(hitPosition.z))); + pickresult.Append(uint4(meshVert, + asuint(hitPosition.x), asuint(hitPosition.y), asuint(hitPosition.z))); } } @@ -292,14 +284,14 @@ void defaultPath(uint threadID) float len = length(scr - PickCoords); if(len < 35.0f) { - pickresult.Append(uint4(vertid, idx, asuint(len), asuint(wpos.z))); + pickresult.Append(uint4(vertid, idx, asuint(len), asuint(wpos.z))); } } [numthreads(1024, 1, 1)] void RENDERDOC_MeshPickCS(uint3 tid : SV_DispatchThreadID) { - if (PickMeshMode == MESH_OTHER) + if (PickMeshMode == MESH_OTHER) { defaultPath(tid.x); } @@ -308,28 +300,3 @@ void RENDERDOC_MeshPickCS(uint3 tid : SV_DispatchThreadID) trianglePath(tid.x); } } - -// -// -// -/* - uint vertid = tid.x; - - if(vertid >= PickNumVerts) - return; - - uint idx = PickIdx ? index[vertid] : vertid; - - float4 pos = vertex[idx]; - - float4 wpos = mul(pos, PickMVP); - - wpos.xyz /= wpos.w; - - float2 scr = (wpos.xy*float2(1.0f, -1.0f) + 1.0f) * 0.5f * PickViewport; - - // close to target co-ords? add to list - float len = length(scr - PickCoords); - if(len < 25.0f) - pickresult.Append(uint4(vertid, idx, asuint(len), asuint(wpos.z))); -*/ \ No newline at end of file diff --git a/renderdoc/driver/d3d11/d3d11_analyse.cpp b/renderdoc/driver/d3d11/d3d11_analyse.cpp index 1b293a4b2..753aed99d 100644 --- a/renderdoc/driver/d3d11/d3d11_analyse.cpp +++ b/renderdoc/driver/d3d11/d3d11_analyse.cpp @@ -37,6 +37,8 @@ #include "d3d11_debug.h" #include "d3d11_manager.h" +#include "data/hlsl/debugcbuffers.h" + // over this number of cycles and things get problematic #define SHADER_DEBUG_WARN_THRESHOLD 100000 @@ -2236,12 +2238,6 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, D3D11RenderStateTracker tracker(m_WrappedContext); -#define MESH_OTHER 0 // this covers points and lines, logic is the same -#define MESH_TRIANGLE_LIST 1 -#define MESH_TRIANGLE_STRIP 2 -#define MESH_TRIANGLE_FAN 3 -#define MESH_TRIANGLE_LIST_ADJ 4 -#define MESH_TRIANGLE_STRIP_ADJ 5 struct MeshPickData { Vec3f RayPos; @@ -2336,11 +2332,6 @@ uint32_t D3D11DebugManager::PickVertex(uint32_t eventID, const MeshDisplay &cfg, cbuf.MeshMode = MESH_TRIANGLE_STRIP; break; }; - case eTopology_TriangleFan: - { - cbuf.MeshMode = MESH_TRIANGLE_FAN; - break; - }; case eTopology_TriangleList_Adj: { cbuf.MeshMode = MESH_TRIANGLE_LIST_ADJ; @@ -3282,8 +3273,6 @@ void D3D11DebugManager::CreateCustomShaderTex(uint32_t w, uint32_t h) } } -#include "data/hlsl/debugcbuffers.h" - ResourceId D3D11DebugManager::RenderOverlay(ResourceId texid, FormatComponentType typeHint, TextureDisplayOverlay overlay, uint32_t eventID, const vector &passEvents) diff --git a/renderdoc/driver/gl/gl_debug.cpp b/renderdoc/driver/gl/gl_debug.cpp index 81e08f207..ee8998c2b 100644 --- a/renderdoc/driver/gl/gl_debug.cpp +++ b/renderdoc/driver/gl/gl_debug.cpp @@ -1007,7 +1007,6 @@ bool GLReplay::GetHistogram(ResourceId texid, uint32_t sliceFace, uint32_t mip, return true; } -// TODO: VS_Out triangles doesn't pick correctly if you look back on the frustrum, (gl as well) uint32_t GLReplay::PickVertex(uint32_t eventID, const MeshDisplay &cfg, uint32_t x, uint32_t y) { WrappedOpenGL &gl = *m_pDriver;