mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-04 17:10:47 +00:00
Create separate shader for sint, uint and floats
Co-authored-by: Orson B <obraines@gmail.com> Signed-off-by: Tony T <tony@tonytascioglu.com>
This commit is contained in:
@@ -25,6 +25,51 @@
|
||||
#include <stdio.h>
|
||||
#include "gl_test.h"
|
||||
|
||||
bool IsUIntFormat(GLenum internalFormat)
|
||||
{
|
||||
switch(internalFormat)
|
||||
{
|
||||
case GL_R8UI:
|
||||
case GL_RG8UI:
|
||||
case GL_RGB8UI:
|
||||
case GL_RGBA8UI:
|
||||
case GL_R16UI:
|
||||
case GL_RG16UI:
|
||||
case GL_RGB16UI:
|
||||
case GL_RGBA16UI:
|
||||
case GL_R32UI:
|
||||
case GL_RG32UI:
|
||||
case GL_RGB32UI:
|
||||
case GL_RGBA32UI:
|
||||
case GL_RGB10_A2UI: return true;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool IsSIntFormat(GLenum internalFormat)
|
||||
{
|
||||
switch(internalFormat)
|
||||
{
|
||||
case GL_R8I:
|
||||
case GL_RG8I:
|
||||
case GL_RGB8I:
|
||||
case GL_RGBA8I:
|
||||
case GL_R16I:
|
||||
case GL_RG16I:
|
||||
case GL_RGB16I:
|
||||
case GL_RGBA16I:
|
||||
case GL_R32I:
|
||||
case GL_RG32I:
|
||||
case GL_RGB32I:
|
||||
case GL_RGBA32I: return true;
|
||||
default: break;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
RD_TEST(GL_Pixel_History, OpenGLGraphicsTest)
|
||||
{
|
||||
static constexpr const char *Description =
|
||||
@@ -36,9 +81,9 @@ RD_TEST(GL_Pixel_History, OpenGLGraphicsTest)
|
||||
|
||||
#define v2f v2f_block \
|
||||
{ \
|
||||
vec4 pos; \
|
||||
vec4 col; \
|
||||
vec4 uv; \
|
||||
vec4 pos; \
|
||||
vec4 col; \
|
||||
vec4 uv; \
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
@@ -53,10 +98,10 @@ out v2f vertOut;
|
||||
|
||||
void main()
|
||||
{
|
||||
vertOut.pos = vec4(Position.xyz, 1);
|
||||
gl_Position = vertOut.pos;
|
||||
vertOut.col = Color;
|
||||
vertOut.uv = vec4(UV.xy, 0, 1);
|
||||
vertOut.pos = vec4(Position.xyz, 1);
|
||||
gl_Position = vertOut.pos;
|
||||
vertOut.col = Color;
|
||||
vertOut.uv = vec4(UV.xy, 0, 1);
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
@@ -69,7 +114,35 @@ layout(location = 0, index = 0) out vec4 Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
Color = vertIn.col;
|
||||
Color = vertIn.col;
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
|
||||
std::string pixelSigned = R"EOSHADER(
|
||||
|
||||
in v2f vertIn;
|
||||
|
||||
layout(location = 0, index = 0) out ivec4 Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 a = vertIn.col * 127.0;
|
||||
Color = ivec4(a.r, a.g, a.b, a.a);
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
|
||||
std::string pixelUnsigned = R"EOSHADER(
|
||||
|
||||
in v2f vertIn;
|
||||
|
||||
layout(location = 0, index = 0) out uvec4 Color;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 a = vertIn.col * 255.0;
|
||||
Color = uvec4(a.r, a.g, a.b, a.a);
|
||||
}
|
||||
|
||||
)EOSHADER";
|
||||
@@ -103,6 +176,8 @@ void main()
|
||||
glEnableVertexAttribArray(2);
|
||||
|
||||
GLuint program = MakeProgram(common + vertex, common + pixel);
|
||||
GLuint programSigned = MakeProgram(common + vertex, common + pixelSigned);
|
||||
GLuint programUnsigned = MakeProgram(common + vertex, common + pixelUnsigned);
|
||||
|
||||
GLenum colorFormats[] = {
|
||||
GL_RGBA8, GL_RGBA16, GL_RGBA16F, GL_RGBA32F, GL_RGBA8I, GL_RGBA8UI,
|
||||
@@ -205,23 +280,21 @@ void main()
|
||||
{
|
||||
if(multisampled)
|
||||
{
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D_MULTISAMPLE,
|
||||
multisampledDepthTextures[h], 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT,
|
||||
GL_TEXTURE_2D_MULTISAMPLE, multisampledDepthTextures[h], 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D,
|
||||
depthTextures[h], 0);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_TEXTURE_2D, 0, 0);
|
||||
}
|
||||
|
||||
GLenum bufs[] = {GL_COLOR_ATTACHMENT0};
|
||||
glDrawBuffers(1, bufs);
|
||||
|
||||
float col[] = {0.2f, 0.2f, 0.2f, 1.0f};
|
||||
GLenum check = glCheckFramebufferStatus(GL_FRAMEBUFFER);
|
||||
if(check != GL_FRAMEBUFFER_COMPLETE)
|
||||
{
|
||||
@@ -232,12 +305,28 @@ void main()
|
||||
continue;
|
||||
}
|
||||
|
||||
glClearBufferfv(GL_COLOR, 0, col);
|
||||
glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0f, 0);
|
||||
|
||||
glBindVertexArray(vao);
|
||||
|
||||
glUseProgram(program);
|
||||
if(IsUIntFormat(colorFormats[i]))
|
||||
{
|
||||
GLuint col[] = {20, 20, 20, 255};
|
||||
glClearBufferuiv(GL_COLOR, 0, col);
|
||||
glUseProgram(programUnsigned);
|
||||
}
|
||||
else if(IsSIntFormat(colorFormats[i]))
|
||||
{
|
||||
GLint col[] = {20, 20, -20, 127};
|
||||
glClearBufferiv(GL_COLOR, 0, col);
|
||||
glUseProgram(programSigned);
|
||||
}
|
||||
else
|
||||
{
|
||||
float col[] = {0.2f, 0.2f, 0.2f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 0, col);
|
||||
glUseProgram(program);
|
||||
}
|
||||
|
||||
glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0f, 0);
|
||||
|
||||
glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
|
||||
|
||||
|
||||
@@ -59,9 +59,8 @@ class GL_Pixel_History(rdtest.TestCase):
|
||||
def check_events(self, events, modifs, hasSecondary):
|
||||
eventMatchingModifs = modifs[(-1 * len(events)):]
|
||||
print(f"Events: {events}, Modifs: {modifs}, EventMatchingModifs: {eventMatchingModifs}")
|
||||
#self.check(len(modifs) == len(events), "Expected {} events, got {}, modifs {}".format(len(events), len(modifs), modifs))
|
||||
|
||||
# modifications can show results from previous colour passes which we don't care about for now, so we only check the last two modifs
|
||||
# modifications can show results from previous colour passes which we don't care about for now, so we only check the last relevant modifs
|
||||
for i in range(len(eventMatchingModifs)):
|
||||
self.check(eventMatchingModifs[i].eventId == events[i], f"Expected event with id {events[i]}, but got {eventMatchingModifs[i].eventId}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user