Test subresource rendering in overlay tests, remove png comparisons

This commit is contained in:
baldurk
2020-03-12 16:51:19 +00:00
parent 954e29df9e
commit 40611a3dde
68 changed files with 767 additions and 601 deletions
Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 954 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

+39 -1
View File
@@ -29,6 +29,15 @@ RD_TEST(D3D11_Overlay_Test, D3D11GraphicsTest)
static constexpr const char *Description =
"Makes a couple of draws that show off all the overlays in some way";
std::string whitePixel = R"EOSHADER(
float4 main() : SV_Target0
{
return float4(1, 1, 1, 1);
}
)EOSHADER";
int main()
{
// initialise, create window, create device, etc
@@ -42,6 +51,7 @@ RD_TEST(D3D11_Overlay_Test, D3D11GraphicsTest)
ID3D11VertexShaderPtr vs = CreateVS(vsblob);
ID3D11PixelShaderPtr ps = CreatePS(psblob);
ID3D11PixelShaderPtr whiteps = CreatePS(Compile(whitePixel, "main", "ps_4_0"));
const DefaultA2V VBData[] = {
// this triangle occludes in depth
@@ -108,6 +118,11 @@ RD_TEST(D3D11_Overlay_Test, D3D11GraphicsTest)
MakeTexture(DXGI_FORMAT_D32_FLOAT_S8X24_UINT, screenWidth, screenHeight).DSV();
ID3D11DepthStencilViewPtr dsv = MakeDSV(depthtex);
ID3D11Texture2DPtr subtex =
MakeTexture(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, screenWidth, screenHeight).RTV().Array(5).Mips(4);
ID3D11RenderTargetViewPtr subrtv =
MakeRTV(subtex).FirstSlice(2).NumSlices(1).FirstMip(2).NumMips(1);
while(Running())
{
IASetVertexBuffer(vb, sizeof(DefaultA2V), 0);
@@ -126,8 +141,15 @@ RD_TEST(D3D11_Overlay_Test, D3D11GraphicsTest)
SetDepthState(depth);
SetStencilRef(0x55);
D3D11_RASTERIZER_DESC raster = GetRasterState();
raster.ScissorEnable = TRUE;
SetRasterState(raster);
RSSetViewport(
{10.0f, 10.0f, (float)screenWidth - 20.0f, (float)screenHeight - 20.0f, 0.0f, 1.0f});
RSSetScissor({0, 0, screenWidth, screenHeight});
ctx->OMSetRenderTargets(1, &bbRTV.GetInterfacePtr(), dsv);
@@ -153,13 +175,29 @@ RD_TEST(D3D11_Overlay_Test, D3D11GraphicsTest)
ctx->Draw(3, 6);
// add a marker so we can easily locate this draw
annot->SetMarker(L"Test Begin");
setMarker("Test Begin");
depth.StencilEnable = TRUE;
depth.FrontFace.StencilFunc = D3D11_COMPARISON_GREATER;
SetDepthState(depth);
ctx->Draw(24, 9);
depth.StencilEnable = FALSE;
depth.DepthFunc = D3D11_COMPARISON_ALWAYS;
SetDepthState(depth);
ctx->PSSetShader(whiteps, NULL, 0);
RSSetViewport({5.0f, 5.0f, float(screenWidth) / 4.0f - 10.0f,
float(screenHeight) / 4.0f - 10.0f, 0.0f, 1.0f});
RSSetScissor({0, 0, screenWidth / 4, screenHeight / 4});
ClearRenderTargetView(subrtv, {0.0f, 0.0f, 0.0f, 1.0f});
ctx->OMSetRenderTargets(1, &subrtv.GetInterfacePtr(), NULL);
setMarker("Subresources");
ctx->Draw(24, 9);
Present();
}
+5
View File
@@ -418,6 +418,11 @@ void D3D11GraphicsTest::RSSetViewport(D3D11_VIEWPORT view)
ctx->RSSetViewports(1, &view);
}
void D3D11GraphicsTest::RSSetScissor(D3D11_RECT scissor)
{
ctx->RSSetScissorRects(1, &scissor);
}
D3D11_RASTERIZER_DESC D3D11GraphicsTest::GetRasterState()
{
ID3D11RasterizerState *state = NULL;
+1
View File
@@ -146,6 +146,7 @@ struct D3D11GraphicsTest : public GraphicsTest
D3D11_RASTERIZER_DESC GetRasterState();
void SetRasterState(const D3D11_RASTERIZER_DESC &desc);
void RSSetViewport(D3D11_VIEWPORT view);
void RSSetScissor(D3D11_RECT scissor);
D3D11_DEPTH_STENCIL_DESC GetDepthState();
void SetDepthState(const D3D11_DEPTH_STENCIL_DESC &desc);
+43 -1
View File
@@ -29,6 +29,15 @@ RD_TEST(D3D12_Overlay_Test, D3D12GraphicsTest)
static constexpr const char *Description =
"Makes a couple of draws that show off all the overlays in some way";
std::string whitePixel = R"EOSHADER(
float4 main() : SV_Target0
{
return float4(1, 1, 1, 1);
}
)EOSHADER";
int main()
{
// initialise, create window, create device, etc
@@ -37,6 +46,7 @@ RD_TEST(D3D12_Overlay_Test, D3D12GraphicsTest)
ID3DBlobPtr vsblob = Compile(D3DDefaultVertex, "main", "vs_4_0");
ID3DBlobPtr psblob = Compile(D3DDefaultPixel, "main", "ps_4_0");
ID3DBlobPtr whitepsblob = Compile(whitePixel, "main", "ps_4_0");
const DefaultA2V VBData[] = {
// this triangle occludes in depth
@@ -133,12 +143,23 @@ RD_TEST(D3D12_Overlay_Test, D3D12GraphicsTest)
creator.GraphicsDesc.DepthStencilState.FrontFace.StencilFunc = D3D12_COMPARISON_FUNC_GREATER;
ID3D12PipelineStatePtr pipe = creator;
creator.GraphicsDesc.DepthStencilState.StencilEnable = FALSE;
creator.GraphicsDesc.DepthStencilState.DepthFunc = D3D12_COMPARISON_FUNC_ALWAYS;
creator.PS(whitepsblob);
ID3D12PipelineStatePtr whitepipe = creator;
ResourceBarrier(vb, D3D12_RESOURCE_STATE_COMMON, D3D12_RESOURCE_STATE_VERTEX_AND_CONSTANT_BUFFER);
ID3D12ResourcePtr dsv = MakeTexture(DXGI_FORMAT_D32_FLOAT_S8X24_UINT, screenWidth, screenHeight)
.DSV()
.InitialState(D3D12_RESOURCE_STATE_DEPTH_WRITE);
ID3D12ResourcePtr subtex = MakeTexture(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB, screenWidth, screenHeight)
.RTV()
.Array(5)
.Mips(4)
.InitialState(D3D12_RESOURCE_STATE_RENDER_TARGET);
while(Running())
{
ID3D12GraphicsCommandListPtr cmd = GetCommandBuffer();
@@ -177,11 +198,32 @@ RD_TEST(D3D12_Overlay_Test, D3D12GraphicsTest)
cmd->DrawInstanced(3, 1, 6, 0);
// add a marker so we can easily locate this draw
cmd->SetMarker(1, "Test Begin", sizeof("Test Begin") - 1);
setMarker(cmd, "Test Begin");
cmd->SetPipelineState(pipe);
cmd->DrawInstanced(24, 1, 9, 0);
D3D12_CPU_DESCRIPTOR_HANDLE subrtv = MakeRTV(subtex)
.Format(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
.FirstSlice(2)
.NumSlices(1)
.FirstMip(2)
.NumMips(1)
.CreateCPU(1);
RSSetViewport(cmd, {5.0f, 5.0f, float(screenWidth) / 4.0f - 10.0f,
float(screenHeight) / 4.0f - 10.0f, 0.0f, 1.0f});
RSSetScissorRect(cmd, {0, 0, screenWidth / 4, screenHeight / 4});
OMSetRenderTargets(cmd, {subrtv}, {});
ClearRenderTargetView(cmd, subrtv, {0.0f, 0.0f, 0.0f, 1.0f});
cmd->SetPipelineState(whitepipe);
setMarker(cmd, "Subresources");
cmd->DrawInstanced(24, 1, 9, 0);
FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
cmd->Close();
+39 -2
View File
@@ -71,6 +71,18 @@ void main()
Color = vertIn.col;
}
)EOSHADER";
std::string whitepixel = R"EOSHADER(
#version 420 core
layout(location = 0, index = 0) out vec4 Color;
void main()
{
Color = vec4(1,1,1,1);
}
)EOSHADER";
int main()
@@ -157,6 +169,7 @@ void main()
glEnableVertexAttribArray(2);
GLuint program = MakeProgram(common + vertex, common + pixel);
GLuint whiteprogram = MakeProgram(common + vertex, whitepixel);
GLuint fbo = MakeFBO();
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
@@ -173,6 +186,14 @@ void main()
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_TEXTURE_2D,
attachments[1], 0);
GLuint subtex = MakeTexture();
glBindTexture(GL_TEXTURE_2D_ARRAY, subtex);
glTexStorage3D(GL_TEXTURE_2D_ARRAY, 4, GL_SRGB8_ALPHA8, screenWidth, screenHeight, 5);
GLuint subfbo = MakeFBO();
glBindFramebuffer(GL_FRAMEBUFFER, subfbo);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, subtex, 2, 2);
while(Running())
{
glBindVertexArray(vao);
@@ -184,12 +205,14 @@ void main()
glDepthMask(GL_TRUE);
glEnable(GL_DEPTH_TEST);
glEnable(GL_SCISSOR_TEST);
glDisable(GL_DEPTH_CLAMP);
glDisable(GL_STENCIL_TEST);
glStencilOp(GL_KEEP, GL_KEEP, GL_REPLACE);
glStencilFunc(GL_ALWAYS, 0x55, 0xff);
glViewport(10, 10, GLsizei(screenWidth) - 20, GLsizei(screenHeight) - 20);
glScissor(0, 0, screenWidth, screenHeight);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
float col[] = {0.2f, 0.2f, 0.2f, 1.0f};
@@ -210,8 +233,7 @@ void main()
glDrawArrays(GL_TRIANGLES, 6, 3);
// add a marker so we can easily locate this draw
glDebugMessageInsert(GL_DEBUG_SOURCE_APPLICATION, GL_DEBUG_TYPE_MARKER, 0,
GL_DEBUG_SEVERITY_HIGH, -1, "Test Begin");
setMarker("Test Begin");
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_GREATER, 0x55, 0xff);
@@ -222,6 +244,21 @@ void main()
glBlitFramebuffer(0, 0, screenWidth, screenHeight, 0, 0, screenWidth, screenHeight,
GL_COLOR_BUFFER_BIT, GL_LINEAR);
glBindFramebuffer(GL_FRAMEBUFFER, subfbo);
float col2[] = {0.0f, 0.0f, 0.0f, 1.0f};
glClearBufferfv(GL_COLOR, 0, col2);
glDepthFunc(GL_ALWAYS);
glDisable(GL_STENCIL_TEST);
glUseProgram(whiteprogram);
glViewport(5, 5, GLsizei(screenWidth) / 4 - 10, GLsizei(screenHeight) / 4 - 10);
glScissor(0, 0, screenWidth / 4, screenHeight / 4);
setMarker("Subresources");
glDrawArrays(GL_TRIANGLES, 9, 24);
Present();
}
+78 -11
View File
@@ -71,6 +71,18 @@ void main()
Color = vertIn.col;
}
)EOSHADER";
std::string whitepixel = R"EOSHADER(
#version 420 core
layout(location = 0, index = 0) out vec4 Color;
void main()
{
Color = vec4(1,1,1,1);
}
)EOSHADER";
int main()
@@ -176,7 +188,8 @@ void main()
vkh::RenderPassCreator renderPassCreateInfo;
renderPassCreateInfo.attachments.push_back(vkh::AttachmentDescription(
mainWindow->format, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_GENERAL));
mainWindow->format, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL,
VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_STORE));
renderPassCreateInfo.attachments.push_back(vkh::AttachmentDescription(
VK_FORMAT_D32_SFLOAT_S8_UINT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL,
VK_ATTACHMENT_LOAD_OP_CLEAR, VK_ATTACHMENT_STORE_OP_DONT_CARE, VK_SAMPLE_COUNT_1_BIT,
@@ -239,14 +252,39 @@ void main()
pipeCreateInfo.depthStencilState.front.compareOp = VK_COMPARE_OP_GREATER;
VkPipeline pipe = createGraphicsPipeline(pipeCreateInfo);
renderPassCreateInfo.attachments.pop_back();
renderPassCreateInfo.subpasses[0].pDepthStencilAttachment = NULL;
VkRenderPass subrp = createRenderPass(renderPassCreateInfo);
pipeCreateInfo.stages[1] =
CompileShaderModule(whitepixel, ShaderLang::glsl, ShaderStage::frag, "main");
pipeCreateInfo.renderPass = subrp;
pipeCreateInfo.depthStencilState.stencilTestEnable = VK_FALSE;
pipeCreateInfo.depthStencilState.depthCompareOp = VK_COMPARE_OP_ALWAYS;
VkPipeline whitepipe = createGraphicsPipeline(pipeCreateInfo);
AllocatedImage subimg(
this,
vkh::ImageCreateInfo(mainWindow->scissor.extent.width, mainWindow->scissor.extent.height, 0,
mainWindow->format, VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT, 4, 5),
VmaAllocationCreateInfo({0, VMA_MEMORY_USAGE_GPU_ONLY}));
VkImageView subview = createImageView(vkh::ImageViewCreateInfo(
subimg.image, VK_IMAGE_VIEW_TYPE_2D, mainWindow->format, {},
vkh::ImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 2, 1, 2, 1)));
VkFramebuffer subfb = createFramebuffer(vkh::FramebufferCreateInfo(
subrp, {subview},
{mainWindow->scissor.extent.width / 4, mainWindow->scissor.extent.height / 4}));
while(Running())
{
VkCommandBuffer cmd = GetCommandBuffer();
vkBeginCommandBuffer(cmd, vkh::CommandBufferBeginInfo());
VkImage swapimg =
StartUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
StartUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
VkViewport v = mainWindow->viewport;
v.x += 10.0f;
@@ -265,14 +303,11 @@ void main()
vkCmdSetScissor(cmd, 0, 1, &mainWindow->scissor);
vkh::cmdBindVertexBuffers(cmd, 0, {vb.buffer}, {0});
vkCmdClearColorImage(cmd, swapimg, VK_IMAGE_LAYOUT_GENERAL,
vkh::ClearColorValue(0.2f, 0.2f, 0.2f, 1.0f), 1,
vkh::ImageSubresourceRange());
vkCmdBeginRenderPass(
cmd, vkh::RenderPassBeginInfo(renderPass, fbs[mainWindow->imgIndex], mainWindow->scissor,
{vkh::ClearValue(), vkh::ClearValue(1.0f, 0)}),
VK_SUBPASS_CONTENTS_INLINE);
vkCmdBeginRenderPass(cmd,
vkh::RenderPassBeginInfo(
renderPass, fbs[mainWindow->imgIndex], mainWindow->scissor,
{vkh::ClearValue(0.2f, 0.2f, 0.2f, 1.0f), vkh::ClearValue(1.0f, 0)}),
VK_SUBPASS_CONTENTS_INLINE);
// draw the setup triangles
@@ -293,6 +328,38 @@ void main()
vkCmdEndRenderPass(cmd);
v = mainWindow->viewport;
v.width /= 4.0f;
v.height /= 4.0f;
v.x += 5.0f;
v.y += 5.0f;
v.width -= 10.0f;
v.height -= 10.0f;
if(KHR_maintenance1)
{
v.y += v.height;
v.height = -v.height;
}
VkRect2D s = mainWindow->scissor;
s.extent.width /= 4;
s.extent.height /= 4;
vkCmdSetViewport(cmd, 0, 1, &v);
vkCmdSetScissor(cmd, 0, 1, &s);
vkCmdBeginRenderPass(
cmd, vkh::RenderPassBeginInfo(subrp, subfb, s, {vkh::ClearValue(0.0f, 0.0f, 0.0f, 1.0f)}),
VK_SUBPASS_CONTENTS_INLINE);
vkCmdBindPipeline(cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, whitepipe);
setMarker(cmd, "Subresources");
vkCmdDraw(cmd, 24, 1, 9, 0);
vkCmdEndRenderPass(cmd);
FinishUsingBackbuffer(cmd, VK_ACCESS_TRANSFER_WRITE_BIT, VK_IMAGE_LAYOUT_GENERAL);
vkEndCommandBuffer(cmd);
+1
View File
@@ -5,3 +5,4 @@ from .analyse import *
from .testcase import *
from .shared.Texture_Zoo import *
from .shared.Mesh_Zoo import *
from .shared.Overlay_Test import *
+553
View File
@@ -0,0 +1,553 @@
import renderdoc as rd
import rdtest
from typing import List, Tuple
import time
import os
# Not a direct test, re-used by API-specific tests
class Overlay_Test(rdtest.TestCase):
internal = True
def check_capture(self):
out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture)
self.check(out is not None)
test_marker: rd.DrawcallDescription = self.find_draw("Test")
self.controller.SetFrameEvent(test_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
col_tex: rd.ResourceId = pipe.GetOutputTargets()[0].resourceId
tex = rd.TextureDisplay()
tex.resourceId = col_tex
# Check the actual output is as expected first.
# Background around the outside
self.check_pixel_value(col_tex, 0.1, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(col_tex, 0.8, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(col_tex, 0.5, 0.95, [0.2, 0.2, 0.2, 1.0])
# Large dark grey triangle
self.check_pixel_value(col_tex, 0.5, 0.1, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(col_tex, 0.5, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(col_tex, 0.2, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(col_tex, 0.8, 0.9, [0.1, 0.1, 0.1, 1.0])
# Red upper half triangle
self.check_pixel_value(col_tex, 0.3, 0.4, [1.0, 0.0, 0.0, 1.0])
# Blue lower half triangle
self.check_pixel_value(col_tex, 0.3, 0.6, [0.0, 0.0, 1.0, 1.0])
# Floating clipped triangle
self.check_pixel_value(col_tex, 335, 140, [0.0, 0.0, 0.0, 1.0])
self.check_pixel_value(col_tex, 340, 140, [0.2, 0.2, 0.2, 1.0])
# Triangle size triangles
self.check_pixel_value(col_tex, 200, 51, [1.0, 0.5, 1.0, 1.0])
self.check_pixel_value(col_tex, 200, 65, [1.0, 1.0, 0.0, 1.0])
self.check_pixel_value(col_tex, 200, 79, [0.0, 1.0, 1.0, 1.0])
self.check_pixel_value(col_tex, 200, 93, [0.0, 1.0, 0.0, 1.0])
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
# We'll test the clear-before-X overlays seperately, for both colour and depth
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
continue
rdtest.log.print("Checking overlay {} in main draw".format(str(overlay)))
tex.overlay = overlay
out.SetTextureDisplay(tex)
out.Display()
eps = 1.0 / 256.0
overlay_id: rd.ResourceId = out.GetDebugOverlayTexID()
save_data = rd.TextureSave()
save_data.resourceId = overlay_id
save_data.destType = rd.FileType.PNG
self.controller.SaveTexture(save_data, rdtest.get_tmp_path('asdf.png'))
# We test a few key spots:
# 4 points along the left side of the big triangle, above/in/below its intersection with the tri behind
# 4 points outside all triangles
# The overlap between the big tri and the bottom tri, and between it and the right backface culled tri
# The bottom tri's part that sticks out
# The two parts of the backface culled tri that stick out
# The depth clipped tri, in and out of clipping
# The 4 triangle size test triangles
if overlay == rd.DebugOverlay.Drawcall:
self.check_pixel_value(overlay_id, 150, 90, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 0.0, 0.0, 0.5], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 0.0, 0.0, 0.5], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 0.0, 0.0, 0.5], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 0.0, 0.0, 0.5], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 135, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [0.8, 0.1, 0.8, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [0.8, 0.1, 0.8, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.Wireframe:
# Wireframe we only test a limited set to avoid hitting implementation variations of line raster
# We also have to fudge a little because the lines might land on adjacent pixels
x = 142
picked: rd.PixelValue = self.controller.PickPixel(overlay_id, x, 150, rd.Subresource(), rd.CompType.Typeless)
if picked.floatValue[3] == 0.0:
x = 141
self.check_pixel_value(overlay_id, x, 90, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, x, 130, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, x, 160, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, x, 200, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [200.0/255.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [200.0/255.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [200.0/255.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [200.0/255.0, 1.0, 0.0, 0.0], eps=eps)
y = 149
picked: rd.PixelValue = self.controller.PickPixel(overlay_id, 325, y, rd.Subresource(), rd.CompType.Typeless)
if picked.floatValue[3] == 0.0:
y = 150
self.check_pixel_value(overlay_id, 325, y, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 340, y, [200.0/255.0, 1.0, 0.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.Depth:
self.check_pixel_value(overlay_id, 150, 90, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Intersection with lesser depth - depth fail
self.check_pixel_value(overlay_id, 150, 160, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Backface culled triangle
self.check_pixel_value(overlay_id, 285, 135, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Depth clipped part of tri
self.check_pixel_value(overlay_id, 340, 145, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.Stencil:
self.check_pixel_value(overlay_id, 150, 90, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Intersection with different stencil - stencil fail
self.check_pixel_value(overlay_id, 150, 130, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Backface culled triangle
self.check_pixel_value(overlay_id, 285, 135, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Depth clipped part of tri
self.check_pixel_value(overlay_id, 340, 145, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.BackfaceCull:
self.check_pixel_value(overlay_id, 150, 90, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 1.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [0.0, 1.0, 0.0, 1.0], eps=eps)
# Backface culled triangle
self.check_pixel_value(overlay_id, 285, 135, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [0.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.ViewportScissor:
# Inside viewport
self.check_pixel_value(overlay_id, 50, 50, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], eps=eps)
self.check_pixel_value(overlay_id, 350, 50, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], eps=eps)
self.check_pixel_value(overlay_id, 50, 250, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], eps=eps)
self.check_pixel_value(overlay_id, 350, 250, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], eps=eps)
# Viewport border
self.check_pixel_value(overlay_id, 12, 12, [0.1, 0.1, 0.1, 1.0], eps=eps)
# Outside viewport (not on scissor border)
self.check_pixel_value(overlay_id, 6, 6, [0.0, 0.0, 0.0, 0.0], eps=eps)
# Scissor border
self.check_pixel_value(overlay_id, 0, 0, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 20, 0, [0.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 40, 0, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 60, 0, [0.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 60, 0, [0.0, 0.0, 0.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.QuadOverdrawDraw:
self.check_pixel_value(overlay_id, 150, 90, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 135, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [1.0, 1.0, 1.0, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.QuadOverdrawPass:
self.check_pixel_value(overlay_id, 150, 90, [1.0, 1.0, 1.0, 1.0], eps=eps)
# Do an extra tap here where we overlap with the extreme-background largest triangle, to show that
# overdraw
self.check_pixel_value(overlay_id, 150, 100, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [2.0, 2.0, 2.0, 2.0], eps=eps)
# Two of these have overdraw from the pass due to the large background triangle
self.check_pixel_value(overlay_id, 125, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [3.0, 3.0, 3.0, 3.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 135, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [1.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 51, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [2.0, 2.0, 2.0, 2.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [2.0, 2.0, 2.0, 2.0], eps=eps)
elif overlay == rd.DebugOverlay.TriangleSizeDraw:
eps = 1.0
self.check_pixel_value(overlay_id, 150, 90, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [2128.0, 2128.0, 2128.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [2128.0, 2128.0, 2128.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 135, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [531.0, 531.0, 531.0, 531.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.0, 0.0, 0.0, 0.0], eps=eps)
eps = 0.01
self.check_pixel_value(overlay_id, 200, 51, [8.305, 8.305, 8.305, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [5.316, 5.316, 5.316, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [3.0, 3.0, 3.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [1.33, 1.33, 1.33, 1.0], eps=eps)
elif overlay == rd.DebugOverlay.TriangleSizePass:
eps = 1.0
self.check_pixel_value(overlay_id, 150, 90, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 130, [3324.0, 3324.0, 3324.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 160, [3324.0, 3324.0, 3324.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 150, 200, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 125, 250, [43072.0, 43072.0, 43072.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 60, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 250, [43072.0, 43072.0, 43072.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 175, [2128.0, 2128.0, 2128.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 250, 150, [10632.0, 10632.0, 10632.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 220, 190, [2128.0, 2128.0, 2128.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 135, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(overlay_id, 285, 165, [43072.0, 43072.0, 43072.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 330, 145, [531.0, 531.0, 531.0, 531.0], eps=eps)
self.check_pixel_value(overlay_id, 340, 145, [0.0, 0.0, 0.0, 0.0], eps=eps)
eps = 0.01
self.check_pixel_value(overlay_id, 200, 51, [8.305, 8.305, 8.305, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 65, [5.316, 5.316, 5.316, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 79, [3.0, 3.0, 3.0, 1.0], eps=eps)
self.check_pixel_value(overlay_id, 200, 93, [1.33, 1.33, 1.33, 1.0], eps=eps)
rdtest.log.success("Picked pixels are as expected for {}".format(str(overlay)))
# Now check clear-before-X by hand, for colour and for depth
depth_tex: rd.ResourceId = pipe.GetDepthTarget().resourceId
eps = 1.0/256.0
# Check colour and depth before-hand
self.check_pixel_value(col_tex, 250, 250, [0.1, 0.1, 0.1, 1.0], eps=eps)
self.check_pixel_value(col_tex, 125, 125, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 125, 175, [0.0, 0.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 50, 50, [0.2, 0.2, 0.2, 1.0], eps=eps)
self.check_pixel_value(col_tex, 291, 150, [0.977, 0.977, 0.977, 1.0], eps=0.075)
self.check_pixel_value(col_tex, 200, 51, [1.0, 0.5, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 65, [1.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 79, [0.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
eps = 0.001
self.check_pixel_value(depth_tex, 160, 135, [0.9, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 160, 165, [0.0, 0.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 150, [0.5, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 250, [0.95, 0.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 50, 50, [1.0, 0.0/255.0, 0.0, 1.0], eps=eps)
# Check clear before pass
tex.resourceId = col_tex
tex.overlay = rd.DebugOverlay.ClearBeforePass
out.SetTextureDisplay(tex)
out.Display()
eps = 1.0/256.0
self.check_pixel_value(col_tex, 250, 250, [0.1, 0.1, 0.1, 1.0], eps=eps)
self.check_pixel_value(col_tex, 125, 125, [1.0, 0.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 125, 175, [0.0, 0.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 50, 50, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(col_tex, 291, 150, [0.977, 0.977, 0.977, 1.0], eps=0.075)
self.check_pixel_value(col_tex, 200, 51, [1.0, 0.5, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 65, [1.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 79, [0.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
tex.resourceId = depth_tex
tex.overlay = rd.DebugOverlay.ClearBeforePass
out.SetTextureDisplay(tex)
out.Display()
eps = 0.001
self.check_pixel_value(depth_tex, 160, 135, [0.9, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 160, 165, [0.0, 0.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 150, [0.5, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 250, [0.95, 0.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 50, 50, [1.0, 0.0/255.0, 0.0, 1.0], eps=eps)
rdtest.log.success("Clear before pass colour and depth values as expected")
# Check clear before draw
tex.resourceId = col_tex
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
out.SetTextureDisplay(tex)
out.Display()
eps = 1.0/256.0
# These are all pass triangles, should be cleared
self.check_pixel_value(col_tex, 250, 250, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(col_tex, 125, 125, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(col_tex, 125, 175, [0.0, 0.0, 0.0, 0.0], eps=eps)
self.check_pixel_value(col_tex, 50, 50, [0.0, 0.0, 0.0, 0.0], eps=eps)
# These should be identical
self.check_pixel_value(col_tex, 291, 150, [0.977, 0.977, 0.977, 1.0], eps=0.075)
self.check_pixel_value(col_tex, 200, 51, [1.0, 0.5, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 65, [1.0, 1.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 79, [0.0, 1.0, 1.0, 1.0], eps=eps)
self.check_pixel_value(col_tex, 200, 93, [0.0, 1.0, 0.0, 1.0], eps=eps)
tex.resourceId = depth_tex
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
out.SetTextureDisplay(tex)
out.Display()
eps = 0.001
# Without the pass, depth/stencil results are different
self.check_pixel_value(depth_tex, 160, 135, [0.5, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 160, 165, [0.5, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 150, [0.5, 85.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 250, 250, [1.0, 0.0/255.0, 0.0, 1.0], eps=eps)
self.check_pixel_value(depth_tex, 50, 50, [1.0, 0.0/255.0, 0.0, 1.0], eps=eps)
rdtest.log.success("Clear before draw colour and depth values as expected")
rdtest.log.success("All overlays as expected for main draw")
# Now test overlays on a render-to-slice/mip case
sub_marker: rd.DrawcallDescription = self.find_draw("Subresources")
self.controller.SetFrameEvent(sub_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
col_tex = pipe.GetOutputTargets()[0].resourceId
sub = rd.Subresource(pipe.GetOutputTargets()[0].firstMip, 0, 0)
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
continue
rdtest.log.success("Checking overlay {} with mip/slice rendering".format(str(overlay)))
tex.resourceId = col_tex
tex.overlay = overlay
tex.subresource = sub
out.SetTextureDisplay(tex)
out.Display()
overlay_id: rd.ResourceId = out.GetDebugOverlayTexID()
# All values in other mips should be 0 for all overlays
self.check_pixel_value(overlay_id, 200, 150, [0.0, 0.0, 0.0, 0.0], sub=rd.Subresource(0, 0, 0))
self.check_pixel_value(overlay_id, 197, 147, [0.0, 0.0, 0.0, 0.0], sub=rd.Subresource(0, 0, 0))
self.check_pixel_value(overlay_id, 203, 153, [0.0, 0.0, 0.0, 0.0], sub=rd.Subresource(0, 0, 0))
rdtest.log.success("Mip 0 is empty as expected for overlay {}".format(str(overlay)))
if overlay == rd.DebugOverlay.Drawcall:
self.check_pixel_value(overlay_id, 50, 36, [0.8, 0.1, 0.8, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 30, 36, [0.0, 0.0, 0.0, 0.5], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70, 34, [0.8, 0.1, 0.8, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70, 20, [0.0, 0.0, 0.0, 0.5], sub=sub, eps=eps)
elif overlay == rd.DebugOverlay.Wireframe:
self.check_pixel_value(overlay_id, 36, 36, [200.0/255.0, 1.0, 0.0, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 36, 50, [200.0/255.0, 1.0, 0.0, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 50, 36, [200.0/255.0, 1.0, 0.0, 0.0], sub=sub, eps=eps)
elif overlay == rd.DebugOverlay.Depth or overlay == rd.DebugOverlay.Stencil:
self.check_pixel_value(overlay_id, 50, 36, [0.0, 1.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30, 36, [0.0, 1.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 34, [1.0, 0.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 20, [0.0, 1.0, 0.0, 0.0], sub=sub)
elif overlay == rd.DebugOverlay.BackfaceCull:
self.check_pixel_value(overlay_id, 50, 36, [0.0, 1.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30, 36, [0.0, 1.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 34, [1.0, 0.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 20, [0.0, 1.0, 0.0, 0.0], sub=sub)
elif overlay == rd.DebugOverlay.ViewportScissor:
self.check_pixel_value(overlay_id, 50, 36, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 30, 36, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70, 34, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70, 20, [0.2*0.7, 0.2*0.7, 0.9*0.7, 0.7*0.7], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 6, 6, [0.1, 0.1, 0.1, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 4, 4, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 0, 0, [1.0, 1.0, 1.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 20, 0, [0.0, 0.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 40, 0, [1.0, 1.0, 1.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 60, 0, [0.0, 0.0, 0.0, 1.0], sub=sub)
elif overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass:
self.check_pixel_value(overlay_id, 50, 36, [1.0, 1.0, 1.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30, 36, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 34, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 20, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 50, 45, [2.0, 2.0, 2.0, 2.0], sub=sub)
elif overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass:
self.check_pixel_value(overlay_id, 50, 36, [585.0, 585.0, 585.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30, 36, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 34, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70, 20, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 50, 45, [117.0, 117.0, 117.0, 1.0], sub=sub)
rdtest.log.success("Picked values are correct for mip {} overlay {}".format(sub.mip, str(overlay)))
out.Shutdown()
+2 -146
View File
@@ -2,150 +2,6 @@ import rdtest
import renderdoc as rd
class D3D11_Overlay_Test(rdtest.TestCase):
class D3D11_Overlay_Test(rdtest.Overlay_Test):
demos_test_name = 'D3D11_Overlay_Test'
def check_clearbeforedraw_depth(self, out, depthId):
# Test ClearBeforeDraw with a depth target
tex = rd.TextureDisplay()
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
tex.resourceId = depthId
out.SetTextureDisplay(tex)
out.GetDebugOverlayTexID() # Called to refresh the overlay
overlay = rd.DebugOverlay.ClearBeforeDraw
test_name = str(overlay) + '.Depth'
overlay_path = rdtest.get_tmp_path(test_name + '.png')
ref_path = self.get_ref_path(test_name + '.png')
save_data = rd.TextureSave()
save_data.resourceId = depthId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tolerance = 2
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(test_name), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(test_name))
def check_capture(self):
out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture)
self.check(out is not None)
test_marker: rd.DrawcallDescription = self.find_draw("Test")
self.controller.SetFrameEvent(test_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
tex = rd.TextureDisplay()
tex.resourceId = pipe.GetOutputTargets()[0].resourceId
# Check the actual output is as expected first.
# Background around the outside
self.check_pixel_value(tex.resourceId, 0.1, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.95, [0.2, 0.2, 0.2, 1.0])
# Large dark grey triangle
self.check_pixel_value(tex.resourceId, 0.5, 0.1, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.2, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.9, [0.1, 0.1, 0.1, 1.0])
# Red upper half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.4, [1.0, 0.0, 0.0, 1.0])
# Blue lower half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.6, [0.0, 0.0, 1.0, 1.0])
# Floating clipped triangle
self.check_pixel_value(tex.resourceId, 335, 140, [0.0, 0.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 340, 140, [0.2, 0.2, 0.2, 1.0])
# Triangle size triangles
self.check_pixel_value(tex.resourceId, 200, 51, [1.0, 0.5, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 65, [1.0, 1.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 79, [0.0, 1.0, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 93, [0.0, 1.0, 0.0, 1.0])
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
# Unfortunately line-fill rendering seems to vary too much by IHV, so gives inconsistent results
if overlay == rd.DebugOverlay.Wireframe:
continue
tex.overlay = overlay
out.SetTextureDisplay(tex)
overlay_path = rdtest.get_tmp_path(str(overlay) + '.png')
ref_path = self.get_ref_path(str(overlay) + '.png')
save_data = rd.TextureSave()
save_data.resourceId = out.GetDebugOverlayTexID()
save_data.destType = rd.FileType.PNG
save_data.comp.blackPoint = 0.0
save_data.comp.whitePoint = 1.0
tolerance = 2
# These overlays return grayscale above 1, so rescale to an expected range.
if (overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass or
overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass):
save_data.comp.whitePoint = 10.0
# These overlays modify the underlying texture, so we need to save it out instead of the overlay
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
save_data.resourceId = tex.resourceId
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(str(overlay)), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(str(overlay)))
save_data = rd.TextureSave()
save_data.resourceId = pipe.GetDepthTarget().resourceId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tmp_path = rdtest.get_tmp_path('depth.png')
ref_path = self.get_ref_path('depth.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for depth {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for depth")
save_data.channelExtract = 1
tmp_path = rdtest.get_tmp_path('stencil.png')
ref_path = self.get_ref_path('stencil.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for stencil {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for stencil")
self.check_clearbeforedraw_depth(out, pipe.GetDepthTarget().resourceId)
out.Shutdown()
internal = False
+2 -148
View File
@@ -2,152 +2,6 @@ import rdtest
import renderdoc as rd
class D3D12_Overlay_Test(rdtest.TestCase):
class D3D12_Overlay_Test(rdtest.Overlay_Test):
demos_test_name = 'D3D12_Overlay_Test'
def check_clearbeforedraw_depth(self, out, depthId):
# Test ClearBeforeDraw with a depth target
tex = rd.TextureDisplay()
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
tex.resourceId = depthId
out.SetTextureDisplay(tex)
out.GetDebugOverlayTexID() # Called to refresh the overlay
overlay = rd.DebugOverlay.ClearBeforeDraw
test_name = str(overlay) + '.Depth'
overlay_path = rdtest.get_tmp_path(test_name + '.png')
ref_path = self.get_ref_path(test_name + '.png')
save_data = rd.TextureSave()
save_data.resourceId = depthId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tolerance = 2
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(test_name), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(test_name))
def check_capture(self):
out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture)
self.check(out is not None)
test_marker: rd.DrawcallDescription = self.find_draw("Test")
self.controller.SetFrameEvent(test_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
tex = rd.TextureDisplay()
tex.resourceId = pipe.GetOutputTargets()[0].resourceId
# Check the actual output is as expected first.
# Background around the outside
self.check_pixel_value(tex.resourceId, 0.1, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.95, [0.2, 0.2, 0.2, 1.0])
# Large dark grey triangle
self.check_pixel_value(tex.resourceId, 0.5, 0.1, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.2, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.9, [0.1, 0.1, 0.1, 1.0])
# Red upper half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.4, [1.0, 0.0, 0.0, 1.0])
# Blue lower half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.6, [0.0, 0.0, 1.0, 1.0])
# Floating clipped triangle
self.check_pixel_value(tex.resourceId, 335, 140, [0.0, 0.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 340, 140, [0.2, 0.2, 0.2, 1.0])
# Triangle size triangles
self.check_pixel_value(tex.resourceId, 200, 51, [1.0, 0.5, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 65, [1.0, 1.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 79, [0.0, 1.0, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 93, [0.0, 1.0, 0.0, 1.0])
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
# Unfortunately line-fill rendering seems to vary too much by IHV, so gives inconsistent results
if overlay == rd.DebugOverlay.Wireframe:
continue
tex.overlay = overlay
out.SetTextureDisplay(tex)
overlay_path = rdtest.get_tmp_path(str(overlay) + '.png')
ref_path = self.get_ref_path(str(overlay) + '.png')
save_data = rd.TextureSave()
save_data.resourceId = out.GetDebugOverlayTexID()
save_data.destType = rd.FileType.PNG
save_data.typeCast = rd.CompType.Typeless
save_data.comp.blackPoint = 0.0
save_data.comp.whitePoint = 1.0
tolerance = 2
# These overlays return grayscale above 1, so rescale to an expected range.
if (overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass or
overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass):
save_data.comp.whitePoint = 10.0
# These overlays modify the underlying texture, so we need to save it out instead of the overlay
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
save_data.resourceId = tex.resourceId
save_data.typeCast = rd.CompType.UNormSRGB
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(str(overlay)), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(str(overlay)))
save_data = rd.TextureSave()
save_data.resourceId = pipe.GetDepthTarget().resourceId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tmp_path = rdtest.get_tmp_path('depth.png')
ref_path = self.get_ref_path('depth.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for depth {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for depth")
save_data.channelExtract = 1
tmp_path = rdtest.get_tmp_path('stencil.png')
ref_path = self.get_ref_path('stencil.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for stencil {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for stencil")
self.check_clearbeforedraw_depth(out, pipe.GetDepthTarget().resourceId)
out.Shutdown()
internal = False
+2 -146
View File
@@ -2,150 +2,6 @@ import rdtest
import renderdoc as rd
class GL_Overlay_Test(rdtest.TestCase):
class GL_Overlay_Test(rdtest.Overlay_Test):
demos_test_name = 'GL_Overlay_Test'
def check_clearbeforedraw_depth(self, out, depthId):
# Test ClearBeforeDraw with a depth target
tex = rd.TextureDisplay()
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
tex.resourceId = depthId
out.SetTextureDisplay(tex)
out.GetDebugOverlayTexID() # Called to refresh the overlay
overlay = rd.DebugOverlay.ClearBeforeDraw
test_name = str(overlay) + '.Depth'
overlay_path = rdtest.get_tmp_path(test_name + '.png')
ref_path = self.get_ref_path(test_name + '.png')
save_data = rd.TextureSave()
save_data.resourceId = depthId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tolerance = 2
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(test_name), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(test_name))
def check_capture(self):
out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture)
self.check(out is not None)
test_marker: rd.DrawcallDescription = self.find_draw("Test")
self.controller.SetFrameEvent(test_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
tex = rd.TextureDisplay()
tex.resourceId = pipe.GetOutputTargets()[0].resourceId
# Check the actual output is as expected first.
# Background around the outside
self.check_pixel_value(tex.resourceId, 0.1, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.95, [0.2, 0.2, 0.2, 1.0])
# Large dark grey triangle
self.check_pixel_value(tex.resourceId, 0.5, 0.1, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.2, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.9, [0.1, 0.1, 0.1, 1.0])
# Red upper half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.4, [1.0, 0.0, 0.0, 1.0])
# Blue lower half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.6, [0.0, 0.0, 1.0, 1.0])
# Floating clipped triangle
self.check_pixel_value(tex.resourceId, 335, 140, [0.0, 0.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 340, 140, [0.2, 0.2, 0.2, 1.0])
# Triangle size triangles
self.check_pixel_value(tex.resourceId, 200, 51, [1.0, 0.5, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 65, [1.0, 1.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 79, [0.0, 1.0, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 93, [0.0, 1.0, 0.0, 1.0])
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
# Unfortunately line-fill rendering seems to vary too much by IHV, so gives inconsistent results
if overlay == rd.DebugOverlay.Wireframe:
continue
tex.overlay = overlay
out.SetTextureDisplay(tex)
overlay_path = rdtest.get_tmp_path(str(overlay) + '.png')
ref_path = self.get_ref_path(str(overlay) + '.png')
save_data = rd.TextureSave()
save_data.resourceId = out.GetDebugOverlayTexID()
save_data.destType = rd.FileType.PNG
save_data.comp.blackPoint = 0.0
save_data.comp.whitePoint = 1.0
tolerance = 2
# These overlays return grayscale above 1, so rescale to an expected range.
if (overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass or
overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass):
save_data.comp.whitePoint = 10.0
# These overlays modify the underlying texture, so we need to save it out instead of the overlay
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
save_data.resourceId = tex.resourceId
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(str(overlay)), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(str(overlay)))
save_data = rd.TextureSave()
save_data.resourceId = pipe.GetDepthTarget().resourceId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tmp_path = rdtest.get_tmp_path('depth.png')
ref_path = self.get_ref_path('depth.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for depth {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for depth")
save_data.channelExtract = 1
tmp_path = rdtest.get_tmp_path('stencil.png')
ref_path = self.get_ref_path('stencil.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for stencil {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for stencil")
self.check_clearbeforedraw_depth(out, pipe.GetDepthTarget().resourceId)
out.Shutdown()
internal = False
+2 -146
View File
@@ -2,150 +2,6 @@ import rdtest
import renderdoc as rd
class VK_Overlay_Test(rdtest.TestCase):
class VK_Overlay_Test(rdtest.Overlay_Test):
demos_test_name = 'VK_Overlay_Test'
def check_clearbeforedraw_depth(self, out, depthId):
# Test ClearBeforeDraw with a depth target
tex = rd.TextureDisplay()
tex.overlay = rd.DebugOverlay.ClearBeforeDraw
tex.resourceId = depthId
out.SetTextureDisplay(tex)
out.GetDebugOverlayTexID() # Called to refresh the overlay
overlay = rd.DebugOverlay.ClearBeforeDraw
test_name = str(overlay) + '.Depth'
overlay_path = rdtest.get_tmp_path(test_name + '.png')
ref_path = self.get_ref_path(test_name + '.png')
save_data = rd.TextureSave()
save_data.resourceId = depthId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tolerance = 2
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(test_name), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(test_name))
def check_capture(self):
out: rd.ReplayOutput = self.controller.CreateOutput(rd.CreateHeadlessWindowingData(100, 100), rd.ReplayOutputType.Texture)
self.check(out is not None)
test_marker: rd.DrawcallDescription = self.find_draw("Test")
self.controller.SetFrameEvent(test_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
tex = rd.TextureDisplay()
tex.resourceId = pipe.GetOutputTargets()[0].resourceId
# Check the actual output is as expected first.
# Background around the outside
self.check_pixel_value(tex.resourceId, 0.1, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.1, [0.2, 0.2, 0.2, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.95, [0.2, 0.2, 0.2, 1.0])
# Large dark grey triangle
self.check_pixel_value(tex.resourceId, 0.5, 0.1, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.5, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.2, 0.9, [0.1, 0.1, 0.1, 1.0])
self.check_pixel_value(tex.resourceId, 0.8, 0.9, [0.1, 0.1, 0.1, 1.0])
# Red upper half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.4, [1.0, 0.0, 0.0, 1.0])
# Blue lower half triangle
self.check_pixel_value(tex.resourceId, 0.3, 0.6, [0.0, 0.0, 1.0, 1.0])
# Floating clipped triangle
self.check_pixel_value(tex.resourceId, 335, 140, [0.0, 0.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 340, 140, [0.2, 0.2, 0.2, 1.0])
# Triangle size triangles
self.check_pixel_value(tex.resourceId, 200, 51, [1.0, 0.5, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 65, [1.0, 1.0, 0.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 79, [0.0, 1.0, 1.0, 1.0])
self.check_pixel_value(tex.resourceId, 200, 93, [0.0, 1.0, 0.0, 1.0])
for overlay in rd.DebugOverlay:
if overlay == rd.DebugOverlay.NoOverlay:
continue
# These overlays are just displaymodes really, not actually separate overlays
if overlay == rd.DebugOverlay.NaN or overlay == rd.DebugOverlay.Clipping:
continue
# Unfortunately line-fill rendering seems to vary too much by IHV, so gives inconsistent results
if overlay == rd.DebugOverlay.Wireframe:
continue
tex.overlay = overlay
out.SetTextureDisplay(tex)
overlay_path = rdtest.get_tmp_path(str(overlay) + '.png')
ref_path = self.get_ref_path(str(overlay) + '.png')
save_data = rd.TextureSave()
save_data.resourceId = out.GetDebugOverlayTexID()
save_data.destType = rd.FileType.PNG
save_data.comp.blackPoint = 0.0
save_data.comp.whitePoint = 1.0
tolerance = 2
# These overlays return grayscale above 1, so rescale to an expected range.
if (overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass or
overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass):
save_data.comp.whitePoint = 10.0
# These overlays modify the underlying texture, so we need to save it out instead of the overlay
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
save_data.resourceId = tex.resourceId
self.controller.SaveTexture(save_data, overlay_path)
if not rdtest.png_compare(overlay_path, ref_path, tolerance):
raise rdtest.TestFailureException("Reference and output image differ for overlay {}".format(str(overlay)), overlay_path, ref_path)
rdtest.log.success("Reference and output image are identical for {}".format(str(overlay)))
save_data = rd.TextureSave()
save_data.resourceId = pipe.GetDepthTarget().resourceId
save_data.destType = rd.FileType.PNG
save_data.channelExtract = 0
tmp_path = rdtest.get_tmp_path('depth.png')
ref_path = self.get_ref_path('depth.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for depth {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for depth")
save_data.channelExtract = 1
tmp_path = rdtest.get_tmp_path('stencil.png')
ref_path = self.get_ref_path('stencil.png')
self.controller.SaveTexture(save_data, tmp_path)
if not rdtest.png_compare(tmp_path, ref_path):
raise rdtest.TestFailureException("Reference and output image differ for stencil {}", tmp_path, ref_path)
rdtest.log.success("Reference and output image are identical for stencil")
self.check_clearbeforedraw_depth(out, pipe.GetDepthTarget().resourceId)
out.Shutdown()
internal = False