Skip to content

Commit

Permalink
GS debugger fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
dfranx committed Dec 24, 2020
1 parent a2b1747 commit cd1b6f2
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion libs/SPIRV-VM
Submodule SPIRV-VM updated 1 files
+10 −2 src/opcode_setup.c
10 changes: 5 additions & 5 deletions src/SHADERed/Objects/DebugInformation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2084,7 +2084,7 @@ namespace ed {

// check by name or by location
if ((vsOutName && blockName && strcmp(vsOutName, blockName) == 0) ||
(pixel.VertexShaderOutput[vert][j].return_type == location)) {
(pixel.VertexShaderOutput[vert][j].return_type != -1 && pixel.VertexShaderOutput[vert][j].return_type == location)) {
blockData = &pixel.VertexShaderOutput[vert][j];
break;
}
Expand All @@ -2110,7 +2110,7 @@ namespace ed {
spvm_state_call_function(m_vm);

// check where the new primitive is located
float depth = -INFINITY;
float depth = INFINITY;
for (int p = 0; p < m_pixel->GeometryOutput.size(); p++) {
auto* prim = &m_pixel->GeometryOutput[p];

Expand All @@ -2122,7 +2122,7 @@ namespace ed {
glm::vec4 p2 = (prim->Position[v] / prim->Position[v].w + 1.0f) * 0.5f;

if (isPointInTriangle(m_pixel->RelativeCoordinate, p0, p1, p2)) {
if ((p0.z + p1.z + p2.z) / 3.0f > depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
if ((p0.z + p1.z + p2.z) / 3.0f < depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
depth = (p0.z + p1.z + p2.z) / 3.0f;
m_pixel->GeometrySelectedPrimitive = p;
m_pixel->GeometrySelectedVertex = v;
Expand All @@ -2142,7 +2142,7 @@ namespace ed {
glm::vec4 p1 = (prim->Position[v] / prim->Position[v].w + 1.0f) * 0.5f;

if (isPointOnLine(m_pixel->RelativeCoordinate, p0, p1)) {
if ((p0.z + p1.z) / 2.0f > depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
if ((p0.z + p1.z) / 2.0f < depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
depth = (p0.z + p1.z) / 2.0f;
m_pixel->GeometrySelectedPrimitive = p;
m_pixel->GeometrySelectedVertex = v;
Expand All @@ -2160,7 +2160,7 @@ namespace ed {
glm::vec4 p0 = (prim->Position[v] / prim->Position[v].w + 1.0f) * 0.5f;

if (abs(m_pixel->RelativeCoordinate.x - p0.x) < 0.01f && abs(m_pixel->RelativeCoordinate.y - p0.y) < 0.01f) {
if (p0.z > depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
if (p0.z < depth) { // TODO: this is obviously inaccurate, we should calculate Z that is near the RelativeCoordinate
depth = p0.z / 2.0f;
m_pixel->GeometrySelectedPrimitive = p;
m_pixel->GeometrySelectedVertex = v;
Expand Down
4 changes: 2 additions & 2 deletions src/SHADERed/UI/Debug/GeometryOutputUI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -303,14 +303,14 @@ namespace ed {
glClearBufferfv(GL_COLOR, 0, glm::value_ptr(glm::vec4(0.0f, 0.0f, 0.0f, 1.0f)));
glViewport(0, 0, m_lastFBOWidth, m_lastFBOHeight);

glUseProgram(m_shader);

if (m_is3D) {
glm::mat4 matVP = glm::perspective(glm::radians(45.0f), m_lastFBOWidth / m_lastFBOHeight, 0.1f, 1000.0f) * m_camera.GetMatrix();
glUniformMatrix4fv(m_uMatLoc, 1, GL_FALSE, glm::value_ptr(matVP));
} else
glUniformMatrix4fv(m_uMatLoc, 1, GL_FALSE, glm::value_ptr(glm::mat4(1.0f)));

glUseProgram(m_shader);

glBindVertexArray(m_bufLinesVAO);
glDrawArrays(GL_LINES, 0, m_lines);

Expand Down

0 comments on commit cd1b6f2

Please sign in to comment.