mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Test depth bounds serialisation on GL
This commit is contained in:
@@ -76,6 +76,7 @@ set(OPENGL_SRC
|
||||
gl/gl_callstacks.cpp
|
||||
gl/gl_cbuffer_zoo.cpp
|
||||
gl/gl_depthstencil_fbo.cpp
|
||||
gl/gl_depth_bounds.cpp
|
||||
gl/gl_discard_zoo.cpp
|
||||
gl/gl_draw_zoo.cpp
|
||||
gl/gl_empty_capture.cpp
|
||||
|
||||
@@ -230,6 +230,7 @@
|
||||
<ClCompile Include="gl\gl_callstacks.cpp" />
|
||||
<ClCompile Include="gl\gl_cbuffer_zoo.cpp" />
|
||||
<ClCompile Include="gl\gl_depthstencil_fbo.cpp" />
|
||||
<ClCompile Include="gl\gl_depth_bounds.cpp" />
|
||||
<ClCompile Include="gl\gl_discard_zoo.cpp" />
|
||||
<ClCompile Include="gl\gl_draw_zoo.cpp" />
|
||||
<ClCompile Include="gl\gl_dx_interop.cpp" />
|
||||
|
||||
@@ -625,6 +625,9 @@
|
||||
<ClCompile Include="vk\vk_postponed.cpp">
|
||||
<Filter>Vulkan\demos</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="gl\gl_depth_bounds.cpp">
|
||||
<Filter>OpenGL\demos</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Filter Include="D3D11">
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
/******************************************************************************
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2019-2022 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
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
******************************************************************************/
|
||||
|
||||
#include "gl_test.h"
|
||||
|
||||
RD_TEST(GL_Depth_Bounds, OpenGLGraphicsTest)
|
||||
{
|
||||
static constexpr const char *Description = "Tests of depth bounds and interactions.";
|
||||
|
||||
int main()
|
||||
{
|
||||
// initialise, create window, create context, etc
|
||||
if(!Init())
|
||||
return 3;
|
||||
|
||||
GLuint vao = MakeVAO();
|
||||
glBindVertexArray(vao);
|
||||
|
||||
const DefaultA2V tri[3] = {
|
||||
{Vec3f(-0.5f, -0.5f, -0.9f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 0.0f)},
|
||||
{Vec3f(0.0f, 0.5f, 0.0f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(0.0f, 1.0f)},
|
||||
{Vec3f(0.5f, -0.5f, 0.9f), Vec4f(0.0f, 1.0f, 0.0f, 1.0f), Vec2f(1.0f, 0.0f)},
|
||||
};
|
||||
|
||||
GLuint vb = MakeBuffer();
|
||||
glBindBuffer(GL_ARRAY_BUFFER, vb);
|
||||
glBufferData(GL_ARRAY_BUFFER, sizeof(tri), tri, GL_STATIC_DRAW);
|
||||
|
||||
ConfigureDefaultVAO();
|
||||
|
||||
glDepthBoundsEXT(0.2f, 0.8f);
|
||||
glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
|
||||
glEnable(GL_DEPTH_TEST);
|
||||
glDepthFunc(GL_LEQUAL);
|
||||
glDepthMask(GL_TRUE);
|
||||
|
||||
GLuint program = MakeProgram(GLDefaultVertex, GLDefaultPixel);
|
||||
|
||||
while(Running())
|
||||
{
|
||||
glDisable(GL_DEPTH_BOUNDS_TEST_EXT);
|
||||
float col[] = {1.0f, 0.0f, 1.0f, 1.0f};
|
||||
glClearBufferfv(GL_COLOR, 0, col);
|
||||
glClearBufferfi(GL_DEPTH_STENCIL, 0, 1.0f, 0);
|
||||
|
||||
glBindVertexArray(vao);
|
||||
|
||||
glUseProgram(program);
|
||||
|
||||
glViewport(0, 0, GLsizei(screenWidth), GLsizei(screenHeight));
|
||||
|
||||
glDisable(GL_DEPTH_BOUNDS_TEST_EXT);
|
||||
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
setMarker("Test");
|
||||
|
||||
glEnable(GL_DEPTH_BOUNDS_TEST_EXT);
|
||||
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);
|
||||
glDrawArrays(GL_TRIANGLES, 0, 3);
|
||||
|
||||
Present();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
};
|
||||
|
||||
REGISTER_TEST();
|
||||
@@ -0,0 +1,34 @@
|
||||
import copy
|
||||
import rdtest
|
||||
import renderdoc as rd
|
||||
from typing import Tuple
|
||||
|
||||
|
||||
class GL_Depth_Bounds(rdtest.TestCase):
|
||||
demos_test_name = 'GL_Depth_Bounds'
|
||||
|
||||
def check_capture(self):
|
||||
eid = self.find_action("Test").next.eventId
|
||||
self.controller.SetFrameEvent(eid, False)
|
||||
|
||||
glpipe = self.controller.GetGLPipelineState()
|
||||
|
||||
self.check(glpipe.depthState.depthBounds)
|
||||
|
||||
if (not rdtest.value_compare(glpipe.depthState.nearBound, 0.2) or
|
||||
not rdtest.value_compare(glpipe.depthState.farBound, 0.8)):
|
||||
raise rdtest.TestFailureException("Bounds {} - {} aren't as expected"
|
||||
.format(glpipe.depthState.nearBound, glpipe.depthState.farBound))
|
||||
|
||||
pipe = self.controller.GetPipelineState()
|
||||
|
||||
tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
|
||||
|
||||
self.check_pixel_value(tex, 200, 200, [0.0, 1.0, 0.0, 1.0])
|
||||
self.check_pixel_value(tex, 200, 100, [0.0, 1.0, 0.0, 1.0])
|
||||
self.check_pixel_value(tex, 125, 100, [1.0, 0.0, 1.0, 1.0])
|
||||
self.check_pixel_value(tex, 125, 200, [1.0, 0.0, 1.0, 1.0])
|
||||
self.check_pixel_value(tex, 275, 100, [1.0, 0.0, 1.0, 1.0])
|
||||
self.check_pixel_value(tex, 275, 200, [1.0, 0.0, 1.0, 1.0])
|
||||
|
||||
rdtest.log.success("Triangle is clipped as expected")
|
||||
Reference in New Issue
Block a user