Fix issues switching between mips with overlays on vulkan

This commit is contained in:
baldurk
2020-04-07 14:05:43 +01:00
parent 6c3bf313a4
commit 5e2de7dd34
11 changed files with 233 additions and 105 deletions
+4
View File
@@ -2640,6 +2640,10 @@ rdcarray<uint32_t> D3D12Replay::GetPassEvents(uint32_t eventId)
// step back
const DrawcallDescription *prev = start->previous;
// if the previous is a clear, we're done
if(prev->flags & DrawFlags::Clear)
break;
// if the outputs changed, we're done
if(memcmp(start->outputs, prev->outputs, sizeof(start->outputs)) != 0 ||
start->depthOut != prev->depthOut)
+4 -4
View File
@@ -438,10 +438,6 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, const Subresource &sub, Com
drv.glClearBufferfv(eGL_COLOR, 0, black);
}
// bind the desired mip
drv.glFramebufferTexture2D(eGL_FRAMEBUFFER, eGL_COLOR_ATTACHMENT0, texBindingEnum,
DebugData.overlayTex, sub.mip);
drv.glBindTexture(texBindingEnum, curTex);
}
@@ -450,6 +446,10 @@ ResourceId GLReplay::RenderOverlay(ResourceId texid, const Subresource &sub, Com
drv.glBindFramebuffer(eGL_FRAMEBUFFER, DebugData.overlayFBO);
// bind the desired mip
drv.glFramebufferTexture2D(eGL_FRAMEBUFFER, eGL_COLOR_ATTACHMENT0, texBindingEnum,
DebugData.overlayTex, sub.mip);
// disable several tests/allow rendering - some overlays will override
// these states but commonly we don't want to inherit these states from
// the program's state.
+26 -16
View File
@@ -496,6 +496,8 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, const Subresource &sub,
VkImageSubresourceRange subRange = {VK_IMAGE_ASPECT_COLOR_BIT, sub.mip, 1, 0, 1};
const VkFormat overlayFormat = VK_FORMAT_R16G16B16A16_SFLOAT;
// create the overlay image if we don't have one already
// we go through the driver's creation functions so creation info
// is saved and the resources are registered as live resources for
@@ -512,7 +514,7 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, const Subresource &sub,
NULL,
0,
VK_IMAGE_TYPE_2D,
VK_FORMAT_R16G16B16A16_SFLOAT,
overlayFormat,
{m_Overlay.ImageDim.width, m_Overlay.ImageDim.height, 1},
(uint32_t)iminfo.mipLevels,
1,
@@ -555,21 +557,6 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, const Subresource &sub,
vkr = m_pDriver->vkBindImageMemory(m_Device, m_Overlay.Image, m_Overlay.ImageMem, 0);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
VkImageViewCreateInfo viewInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
NULL,
0,
m_Overlay.Image,
VK_IMAGE_VIEW_TYPE_2D,
imInfo.format,
{VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY},
subRange,
};
vkr = m_pDriver->vkCreateImageView(m_Device, &viewInfo, NULL, &m_Overlay.ImageView);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
// need to update image layout into valid state
m_pDriver->FindImageState(GetResID(m_Overlay.Image))
@@ -614,6 +601,29 @@ ResourceId VulkanReplay::RenderOverlay(ResourceId texid, const Subresource &sub,
vkr = m_pDriver->vkCreateRenderPass(m_Device, &rpinfo, NULL, &m_Overlay.NoDepthRP);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
}
if(m_Overlay.MipLevel != sub.mip || m_Overlay.ImageView == VK_NULL_HANDLE)
{
m_pDriver->vkDestroyFramebuffer(m_Device, m_Overlay.NoDepthFB, NULL);
m_pDriver->vkDestroyImageView(m_Device, m_Overlay.ImageView, NULL);
m_Overlay.MipLevel = sub.mip;
VkImageViewCreateInfo viewInfo = {
VK_STRUCTURE_TYPE_IMAGE_VIEW_CREATE_INFO,
NULL,
0,
m_Overlay.Image,
VK_IMAGE_VIEW_TYPE_2D,
overlayFormat,
{VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY,
VK_COMPONENT_SWIZZLE_IDENTITY, VK_COMPONENT_SWIZZLE_IDENTITY},
subRange,
};
vkr = m_pDriver->vkCreateImageView(m_Device, &viewInfo, NULL, &m_Overlay.ImageView);
RDCASSERTEQUAL(vkr, VK_SUCCESS);
// Create framebuffer rendering just to overlay image, no depth
VkFramebufferCreateInfo fbinfo = {
+4 -1
View File
@@ -582,9 +582,12 @@ private:
VkExtent2D ImageDim = {0, 0};
int32_t MipLevels = 0;
VkSampleCountFlagBits Samples = VK_SAMPLE_COUNT_1_BIT;
VkRenderPass NoDepthRP = VK_NULL_HANDLE;
// the view and framebuffer must be recreated if the mip changes, even if the image doesn't
uint32_t MipLevel = ~0U;
VkImageView ImageView = VK_NULL_HANDLE;
VkFramebuffer NoDepthFB = VK_NULL_HANDLE;
VkRenderPass NoDepthRP = VK_NULL_HANDLE;
VkDescriptorSetLayout m_CheckerDescSetLayout = VK_NULL_HANDLE;
VkPipelineLayout m_CheckerPipeLayout = VK_NULL_HANDLE;
+2 -1
View File
@@ -178,7 +178,8 @@ void ReplayOutput::SetTextureDisplay(const TextureDisplay &o)
m_RenderData.texDisplay.overlay == DebugOverlay::ClearBeforePass);
if(o.overlay != m_RenderData.texDisplay.overlay ||
(o.overlay != DebugOverlay::NoOverlay && (o.typeCast != m_RenderData.texDisplay.typeCast ||
(o.overlay != DebugOverlay::NoOverlay && (o.subresource != m_RenderData.texDisplay.subresource ||
o.typeCast != m_RenderData.texDisplay.typeCast ||
o.resourceId != m_RenderData.texDisplay.resourceId)))
{
if(wasClearBeforeDraw)
+13 -1
View File
@@ -122,6 +122,8 @@ float4 main() : SV_Target0
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);
ID3D11RenderTargetViewPtr subrtv2 =
MakeRTV(subtex).FirstSlice(2).NumSlices(1).FirstMip(3).NumMips(1);
while(Running())
{
@@ -195,7 +197,17 @@ float4 main() : SV_Target0
ClearRenderTargetView(subrtv, {0.0f, 0.0f, 0.0f, 1.0f});
ctx->OMSetRenderTargets(1, &subrtv.GetInterfacePtr(), NULL);
setMarker("Subresources");
setMarker("Subresources mip 2");
ctx->Draw(24, 9);
RSSetViewport(
{2.0f, 2.0f, float(screenWidth / 8) - 4.0f, float(screenHeight / 8) - 4.0f, 0.0f, 1.0f});
RSSetScissor({0, 0, screenWidth / 8, screenHeight / 8});
ClearRenderTargetView(subrtv2, {0.0f, 0.0f, 0.0f, 1.0f});
ctx->OMSetRenderTargets(1, &subrtv2.GetInterfacePtr(), NULL);
setMarker("Subresources mip 3");
ctx->Draw(24, 9);
Present();
+20 -1
View File
@@ -221,7 +221,26 @@ float4 main() : SV_Target0
cmd->SetPipelineState(whitepipe);
setMarker(cmd, "Subresources");
subrtv = MakeRTV(subtex)
.Format(DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
.FirstSlice(2)
.NumSlices(1)
.FirstMip(3)
.NumMips(1)
.CreateCPU(1);
setMarker(cmd, "Subresources mip 2");
cmd->DrawInstanced(24, 1, 9, 0);
RSSetViewport(cmd, {2.0f, 2.0f, float(screenWidth / 8) - 4.0f, float(screenHeight / 8) - 4.0f,
0.0f, 1.0f});
RSSetScissorRect(cmd, {0, 0, screenWidth / 8, screenHeight / 8});
OMSetRenderTargets(cmd, {subrtv}, {});
ClearRenderTargetView(cmd, subrtv, {0.0f, 0.0f, 0.0f, 1.0f});
setMarker(cmd, "Subresources mip 3");
cmd->DrawInstanced(24, 1, 9, 0);
FinishUsingBackbuffer(cmd, D3D12_RESOURCE_STATE_RENDER_TARGET);
+15 -1
View File
@@ -206,6 +206,11 @@ void main()
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, subtex, 2, 2);
GLuint subfbo2 = MakeFBO();
glBindFramebuffer(GL_FRAMEBUFFER, subfbo2);
glFramebufferTextureLayer(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, subtex, 3, 2);
while(Running())
{
glBindVertexArray(vao);
@@ -268,7 +273,16 @@ void main()
glViewport(5, 5, GLsizei(screenWidth) / 4 - 10, GLsizei(screenHeight) / 4 - 10);
glScissor(0, 0, screenWidth / 4, screenHeight / 4);
setMarker("Subresources");
setMarker("Subresources mip 2");
glDrawArrays(GL_TRIANGLES, 9, 24);
glBindFramebuffer(GL_FRAMEBUFFER, subfbo2);
glClearBufferfv(GL_COLOR, 0, col2);
glViewport(2, 2, GLsizei(screenWidth) / 8 - 4, GLsizei(screenHeight) / 8 - 4);
glScissor(0, 0, screenWidth / 8, screenHeight / 8);
setMarker("Subresources mip 3");
glDrawArrays(GL_TRIANGLES, 9, 24);
Present();
+52 -10
View File
@@ -270,13 +270,23 @@ void main()
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)));
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))),
createImageView(vkh::ImageViewCreateInfo(
subimg.image, VK_IMAGE_VIEW_TYPE_2D, mainWindow->format, {},
vkh::ImageSubresourceRange(VK_IMAGE_ASPECT_COLOR_BIT, 3, 1, 2, 1))),
};
VkFramebuffer subfb = createFramebuffer(vkh::FramebufferCreateInfo(
subrp, {subview},
{mainWindow->scissor.extent.width / 4, mainWindow->scissor.extent.height / 4}));
VkFramebuffer subfb[] = {
createFramebuffer(vkh::FramebufferCreateInfo(
subrp, {subview[0]},
{mainWindow->scissor.extent.width / 4, mainWindow->scissor.extent.height / 4})),
createFramebuffer(vkh::FramebufferCreateInfo(
subrp, {subview[1]},
{mainWindow->scissor.extent.width / 8, mainWindow->scissor.extent.height / 8})),
};
while(Running())
{
@@ -349,13 +359,45 @@ void main()
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);
vkCmdBeginRenderPass(cmd, vkh::RenderPassBeginInfo(subrp, subfb[0], 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");
setMarker(cmd, "Subresources mip 2");
vkCmdDraw(cmd, 24, 1, 9, 0);
vkCmdEndRenderPass(cmd);
v = mainWindow->viewport;
v.width /= 8.0f;
v.height /= 8.0f;
v.width = floor(v.width);
v.height = floor(v.height);
v.x += 2.0f;
v.y += 2.0f;
v.width -= 4.0f;
v.height -= 4.0f;
s.extent.width /= 2;
s.extent.height /= 2;
if(KHR_maintenance1)
{
v.y += v.height;
v.height = -v.height;
}
vkCmdSetViewport(cmd, 0, 1, &v);
vkCmdSetScissor(cmd, 0, 1, &s);
vkCmdBeginRenderPass(cmd, vkh::RenderPassBeginInfo(subrp, subfb[1], 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 mip 3");
vkCmdDraw(cmd, 24, 1, 9, 0);
vkCmdEndRenderPass(cmd);
+91 -68
View File
@@ -460,88 +460,111 @@ class Overlay_Test(rdtest.TestCase):
rdtest.log.success("All overlays as expected for main draw")
# Now test overlays on a render-to-slice/mip case
for mip in [2, 3]:
sub_marker: rd.DrawcallDescription = self.find_draw("Subresources mip {}".format(mip))
sub_marker: rd.DrawcallDescription = self.find_draw("Subresources")
self.controller.SetFrameEvent(sub_marker.next.eventId, True)
self.controller.SetFrameEvent(sub_marker.next.eventId, True)
pipe: rd.PipeState = self.controller.GetPipelineState()
pipe: rd.PipeState = self.controller.GetPipelineState()
col_tex = pipe.GetOutputTargets()[0].resourceId
sub = rd.Subresource(pipe.GetOutputTargets()[0].firstMip, 0, 0)
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
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
# 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
if overlay == rd.DebugOverlay.ClearBeforeDraw or overlay == rd.DebugOverlay.ClearBeforePass:
continue
rdtest.log.success("Checking overlay {} with mip/slice rendering".format(str(overlay)))
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)
tex.resourceId = col_tex
tex.overlay = overlay
tex.subresource = sub
out.SetTextureDisplay(tex)
out.Display()
out.Display()
overlay_id: rd.ResourceId = out.GetDebugOverlayTexID()
overlay_id: rd.ResourceId = out.GetDebugOverlayTexID()
shift = 0
if mip == 3:
shift = 1
# 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))
# All values in mip 0 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)))
rdtest.log.success("Other mips are 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)
if overlay == rd.DebugOverlay.Drawcall:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [0.8, 0.1, 0.8, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 30 >> shift, 36 >> shift, [0.0, 0.0, 0.0, 0.5], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70 >> shift, 34 >> shift, [0.8, 0.1, 0.8, 1.0], sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 70 >> shift, 20 >> shift, [0.0, 0.0, 0.0, 0.5], sub=sub, eps=eps)
elif overlay == rd.DebugOverlay.Wireframe:
self.check_pixel_value(overlay_id, 36 >> shift, 36 >> shift, [200.0 / 255.0, 1.0, 0.0, 1.0],
sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 36 >> shift, 50 >> shift, [200.0 / 255.0, 1.0, 0.0, 1.0],
sub=sub, eps=eps)
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [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 >> shift, 36 >> shift, [0.0, 1.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30 >> shift, 36 >> shift, [0.0, 1.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 34 >> shift, [1.0, 0.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 20 >> shift, [0.0, 1.0, 0.0, 0.0], sub=sub)
elif overlay == rd.DebugOverlay.BackfaceCull:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [0.0, 1.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30 >> shift, 36 >> shift, [0.0, 1.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 34 >> shift, [1.0, 0.0, 0.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 20 >> shift, [0.0, 1.0, 0.0, 0.0], sub=sub)
elif overlay == rd.DebugOverlay.ViewportScissor:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift,
[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 >> shift, 36 >> shift,
[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 >> shift, 34 >> shift,
[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 >> shift, 20 >> shift,
[0.2 * 0.7, 0.2 * 0.7, 0.9 * 0.7, 0.7 * 0.7], sub=sub, eps=eps)
rdtest.log.success("Picked values are correct for mip {} overlay {}".format(sub.mip, str(overlay)))
if mip == 2:
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)
else:
self.check_pixel_value(overlay_id, 4, 4, [0.1, 0.1, 0.1, 1.0], sub=sub, eps=eps)
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)
elif overlay == rd.DebugOverlay.QuadOverdrawDraw or overlay == rd.DebugOverlay.QuadOverdrawPass:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [1.0, 1.0, 1.0, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30 >> shift, 36 >> shift, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 20 >> shift, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 50 >> shift, 45 >> shift, [2.0, 2.0, 2.0, 2.0], sub=sub)
elif overlay == rd.DebugOverlay.TriangleSizeDraw or overlay == rd.DebugOverlay.TriangleSizePass:
if mip == 2:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [585.0, 585.0, 585.0, 1.0], sub=sub)
else:
self.check_pixel_value(overlay_id, 50 >> shift, 36 >> shift, [151.75, 151.75, 151.75, 1.0], sub=sub)
self.check_pixel_value(overlay_id, 30 >> shift, 36 >> shift, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 34 >> shift, [0.0, 0.0, 0.0, 0.0], sub=sub)
self.check_pixel_value(overlay_id, 70 >> shift, 20 >> shift, [0.0, 0.0, 0.0, 0.0], sub=sub)
if mip == 2:
self.check_pixel_value(overlay_id, 50 >> shift, 45 >> shift, [117.0, 117.0, 117.0, 1.0], sub=sub)
else:
self.check_pixel_value(overlay_id, 50 >> shift, 45 >> shift, [30.359375, 30.359375, 30.359375, 1.0], sub=sub)
rdtest.log.success("Picked values are correct for mip {} overlay {}".format(sub.mip, str(overlay)))
out.Shutdown()
+2 -2
View File
@@ -321,9 +321,9 @@ class TestCase:
if tex_details is not None:
if type(x) is float:
x = int((tex_details.width-1) * x)
x = int(((tex_details.width >> sub.mip) - 1) * x)
if type(y) is float:
y = int((tex_details.height-1) * y)
y = int(((tex_details.height >> sub.mip) - 1) * y)
if cast == rd.CompType.Typeless and tex_details.creationFlags & rd.TextureCategory.SwapBuffer:
cast = rd.CompType.UNormSRGB