diff --git a/util/test/rdtest/shared/Discard_Zoo.py b/util/test/rdtest/shared/Discard_Zoo.py index 8adba884e..64e551b43 100644 --- a/util/test/rdtest/shared/Discard_Zoo.py +++ b/util/test/rdtest/shared/Discard_Zoo.py @@ -108,7 +108,7 @@ class Discard_Zoo(rdtest.TestCase): if gl and h > 1: y = h - 1 - y - picked = self.controller.PickPixel(id, x, y, sub, rd.CompType.Typeless) + picked = self.pick_pixel(id, x, y, sub, rd.CompType.Typeless) if self.check_val(picked, minval, fmt) or self.check_val(picked, maxval, fmt): raise rdtest.TestFailureException( @@ -130,7 +130,7 @@ class Discard_Zoo(rdtest.TestCase): if gl and h > 1: y = h - 1 - y - picked = self.controller.PickPixel(id, x, y, sub, rd.CompType.Typeless) + picked = self.pick_pixel(id, x, y, sub, rd.CompType.Typeless) is_min = self.check_val(picked, minval, fmt) is_max = self.check_val(picked, maxval, fmt) @@ -158,7 +158,7 @@ class Discard_Zoo(rdtest.TestCase): if gl and h > 1: y = h - 1 - y - picked = self.controller.PickPixel(id, x, y, sub, rd.CompType.Typeless) + picked = self.pick_pixel(id, x, y, sub, rd.CompType.Typeless) is_min = self.check_val(picked, minval, fmt) is_max = self.check_val(picked, maxval, fmt) diff --git a/util/test/rdtest/shared/Overlay_Test.py b/util/test/rdtest/shared/Overlay_Test.py index 68c0a20fb..0248d5df8 100644 --- a/util/test/rdtest/shared/Overlay_Test.py +++ b/util/test/rdtest/shared/Overlay_Test.py @@ -149,10 +149,10 @@ class Overlay_Test(rdtest.TestCase): # Also to be safe we don't run this test on MSAA if not is_msaa: x = 142 - picked = self.controller.PickPixel(overlay_id, x, 150, rd.Subresource(), rd.CompType.Typeless) + picked = self.pick_pixel(overlay_id, x, 150, rd.Subresource(), rd.CompType.Typeless) if picked.floatValue[3] == 0.0: x = 141 - picked = self.controller.PickPixel(overlay_id, x, 150, rd.Subresource(), rd.CompType.Typeless) + picked = self.pick_pixel(overlay_id, x, 150, rd.Subresource(), rd.CompType.Typeless) 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) @@ -165,7 +165,7 @@ class Overlay_Test(rdtest.TestCase): self.check_pixel_value(overlay_id, 250, 250, [200.0/255.0, 1.0, 0.0, 0.0], eps=eps) y = 149 - picked = self.controller.PickPixel(overlay_id, 325, y, rd.Subresource(), rd.CompType.Typeless) + picked = self.pick_pixel(overlay_id, 325, y, rd.Subresource(), rd.CompType.Typeless) if picked.floatValue[3] == 0.0: y = 150 diff --git a/util/test/rdtest/shared/Subgroup_Zoo.py b/util/test/rdtest/shared/Subgroup_Zoo.py index 038d6cad8..7849ef69d 100644 --- a/util/test/rdtest/shared/Subgroup_Zoo.py +++ b/util/test/rdtest/shared/Subgroup_Zoo.py @@ -165,7 +165,7 @@ class Subgroup_Zoo(rdtest.TestCase): for view in range(pipe.MultiviewBroadcastCount()): x, y = pixel - picked = self.controller.PickPixel( + picked = self.pick_pixel( target, x, y, rd.Subresource(0, 0, 0), rd.CompType.Float ) diff --git a/util/test/rdtest/shared/Texture_Zoo.py b/util/test/rdtest/shared/Texture_Zoo.py index c20d9d3cd..912bde9d1 100644 --- a/util/test/rdtest/shared/Texture_Zoo.py +++ b/util/test/rdtest/shared/Texture_Zoo.py @@ -44,7 +44,7 @@ class Texture_Zoo(): if self.opengl_mode: y = max(1, self.textures[tex].height >> sub.mip) - 1 - y - return self.controller.PickPixel(tex, x, y, sub, typeCast) + return self.test.pick_pixel(tex, x, y, sub, typeCast) TEST_CAPTURE = 0 TEST_DDS = 1 @@ -577,7 +577,7 @@ class Texture_Zoo(): comp_type = rd.CompType.Typeless # test that pixel picking sees the right things - picked = self.controller.PickPixel(tex_id, 15, 15, cur_sub, comp_type) + picked = self.test.pick_pixel(tex_id, 15, 15, cur_sub, comp_type) if not rdtest.value_compare(picked.floatValue, expected): raise rdtest.TestFailureException( diff --git a/util/test/rdtest/testcase.py b/util/test/rdtest/testcase.py index 643bc7ef4..a52528d3d 100644 --- a/util/test/rdtest/testcase.py +++ b/util/test/rdtest/testcase.py @@ -214,6 +214,16 @@ class HistoryContext(ScopedContext): def get_history(self): return self.test.controller.PixelHistory(self.tex, self.x, self.y, self.sub, self.cast) +class PickContext(ScopedContext): + def __init__(self, test: TestCase, tex: rd.ResourceId, x: int, y: int, sub: rd.Subresource, cast: rd.CompType): + self.tex = tex + self.x = x + self.y = y + self.sub = sub + self.cast = cast + + super().__init__(test) + class TestCase: slow_test = False internal = False @@ -347,6 +357,13 @@ class TestCase: def debug_thread(self, group: Tuple[int,int,int], thread: Tuple[int,int,int]): return ComputeDebugContext(self, group, thread) + def pick_pixel(self, textureId: rd.ResourceId, x: int, y: int, sub: rd.Subresource, typeCast: rd.CompType): + # just keep the last pick context. We can use this if we don't have anything better, since pixel picking + # isn't as easily 'scoped' as the others + self.contexts = list(filter(lambda x: not isinstance(x, PickContext), self.contexts)) + self.contexts.append(PickContext(self, textureId, x, y, sub, typeCast)) + return self.controller.PickPixel(textureId, x, y, sub, typeCast) + def log_context(self): log.print(f"Current Event: {self.cur_event}") for c in self.contexts: @@ -359,6 +376,10 @@ class TestCase: if isinstance(c, ComputeDebugContext): log.print(f"Executed compute debug on group {c.group} thread {c.thread}") + if len(self.contexts) == 1 and isinstance(self.contexts[0], PickContext): + c = self.contexts[0] + log.print(f"Last Pixel pick on {c.x},{c.y} in {c.tex}") + def _find_action(self, name: str, start_event: int, action_list: List[rd.ActionDescription]) -> rd.ActionDescription | None: bestMatch = None distance = 1000000 @@ -579,7 +600,7 @@ class TestCase: assert type(x) is int and type(y) is int - picked = self.controller.PickPixel(tex, x, y, sub, cast) + picked = self.pick_pixel(tex, x, y, sub, cast) picked_value = picked.floatValue if cast == rd.CompType.UInt: diff --git a/util/test/tests/D3D11/D3D11_AMD_Shader_Extensions.py b/util/test/tests/D3D11/D3D11_AMD_Shader_Extensions.py index c84345ccd..f92cb55f7 100644 --- a/util/test/tests/D3D11/D3D11_AMD_Shader_Extensions.py +++ b/util/test/tests/D3D11/D3D11_AMD_Shader_Extensions.py @@ -17,15 +17,15 @@ class D3D11_AMD_Shader_Extensions(rdtest.TestCase): # Without relying on barycentric order, ensure that the three pixels are red, green, and blue pixels: List[rdtest.VectorValue] = [] - picked = self.controller.PickPixel( + picked = self.pick_pixel( action.copyDestination, 125, 215, rd.Subresource(), rd.CompType.UNorm ) pixels.append(picked.floatValue[0:4]) - picked = self.controller.PickPixel( + picked = self.pick_pixel( action.copyDestination, 200, 85, rd.Subresource(), rd.CompType.UNorm ) pixels.append(picked.floatValue[0:4]) - picked = self.controller.PickPixel( + picked = self.pick_pixel( action.copyDestination, 285, 215, rd.Subresource(), rd.CompType.UNorm ) pixels.append(picked.floatValue[0:4]) diff --git a/util/test/tests/D3D12/D3D12_AMD_Shader_Extensions.py b/util/test/tests/D3D12/D3D12_AMD_Shader_Extensions.py index 9c1ed74d9..2b0f394bf 100644 --- a/util/test/tests/D3D12/D3D12_AMD_Shader_Extensions.py +++ b/util/test/tests/D3D12/D3D12_AMD_Shader_Extensions.py @@ -24,11 +24,11 @@ class D3D12_AMD_Shader_Extensions(rdtest.TestCase): x, y = self.get_view_centre() - picked = self.controller.PickPixel(tex, x+ 0, y+ 0, rd.Subresource(), rd.CompType.UNorm) + picked = self.pick_pixel(tex, x+ 0, y+ 0, rd.Subresource(), rd.CompType.UNorm) pixels.append(picked.floatValue[0:4]) - picked = self.controller.PickPixel(tex, x-20, y+20, rd.Subresource(), rd.CompType.UNorm) + picked = self.pick_pixel(tex, x-20, y+20, rd.Subresource(), rd.CompType.UNorm) pixels.append(picked.floatValue[0:4]) - picked = self.controller.PickPixel(tex, x+20, y+20, rd.Subresource(), rd.CompType.UNorm) + picked = self.pick_pixel(tex, x+20, y+20, rd.Subresource(), rd.CompType.UNorm) pixels.append(picked.floatValue[0:4]) if (not (1.0, 0.0, 0.0, 1.0) in pixels) or (not (1.0, 0.0, 0.0, 1.0) in pixels) or ( diff --git a/util/test/tests/D3D12/D3D12_Execute_Indirect.py b/util/test/tests/D3D12/D3D12_Execute_Indirect.py index e598e0089..77f6e8d69 100644 --- a/util/test/tests/D3D12/D3D12_Execute_Indirect.py +++ b/util/test/tests/D3D12/D3D12_Execute_Indirect.py @@ -36,7 +36,7 @@ class D3D12_Execute_Indirect(rdtest.TestCase): if overlay == rd.DebugOverlay.ClearBeforePass: overlayTex = col_tex - picked = self.controller.PickPixel(overlayTex, x, y, rd.Subresource(), rd.CompType.UNorm) + picked = self.pick_pixel(overlayTex, x, y, rd.Subresource(), rd.CompType.UNorm) emptyPixel = (0.0, 0.0, 0.0, 0.0) if picked.floatValue == emptyPixel: raise rdtest.TestFailureException(f"{overlay.name} overlay is empty") @@ -251,7 +251,7 @@ class D3D12_Execute_Indirect(rdtest.TestCase): count = 0 draws: List[int] = [] for i, p in enumerate(drawPoints): - picked = self.controller.PickPixel(out, p[0], p[1], rd.Subresource(), rd.CompType.UNorm) + picked = self.pick_pixel(out, p[0], p[1], rd.Subresource(), rd.CompType.UNorm) if rdtest.value_compare(picked.floatValue, [0.0, 1.0, 0.0, 1.0]): count += 1 draws += [i] diff --git a/util/test/tests/D3D12/D3D12_Shader_DebugData_Zoo.py b/util/test/tests/D3D12/D3D12_Shader_DebugData_Zoo.py index 1cb9f7e0e..9c482d593 100644 --- a/util/test/tests/D3D12/D3D12_Shader_DebugData_Zoo.py +++ b/util/test/tests/D3D12/D3D12_Shader_DebugData_Zoo.py @@ -152,7 +152,7 @@ class D3D12_Shader_DebugData_Zoo(rdtest.TestCase): x = 4 * test y = 0 self.check_pixel_value(tex, x, y, debugged.value.f32v[0:4]) - picked = rd.PixelValue = self.controller.PickPixel(tex, x, y, rd.Subresource(0,0,0), rd.CompType.Typeless) + picked = rd.PixelValue = self.pick_pixel(tex, x, y, rd.Subresource(0,0,0), rd.CompType.Typeless) realTestResult = picked.floatValue debugInfo = pipe.GetShaderReflection(rd.ShaderStage.Pixel).debugInfo shaderSrcRaw = debugInfo.files[0].contents diff --git a/util/test/tests/D3D12/D3D12_VRS.py b/util/test/tests/D3D12/D3D12_VRS.py index c78aa930f..d2b942dec 100644 --- a/util/test/tests/D3D12/D3D12_VRS.py +++ b/util/test/tests/D3D12/D3D12_VRS.py @@ -19,10 +19,10 @@ class D3D12_VRS(rdtest.TestCase): self.get_shading_rate_for_quad(tex, x + 74, y + 42)) def get_shading_rate_for_quad(self, tex: rd.ResourceId, x: int, y: int): - picked = [self.controller.PickPixel(tex, x+0, y+0, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+1, y+0, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+0, y+1, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+1, y+1, rd.Subresource(), rd.CompType.Typeless)] + picked = [self.pick_pixel(tex, x+0, y+0, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+1, y+0, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+0, y+1, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+1, y+1, rd.Subresource(), rd.CompType.Typeless)] # all same - 2x2 if all([p.floatValue == picked[0].floatValue for p in picked]): diff --git a/util/test/tests/D3D12/D3D12_Vertex_UAV.py b/util/test/tests/D3D12/D3D12_Vertex_UAV.py index c484ea86c..f6debb260 100644 --- a/util/test/tests/D3D12/D3D12_Vertex_UAV.py +++ b/util/test/tests/D3D12/D3D12_Vertex_UAV.py @@ -36,7 +36,7 @@ class D3D12_Vertex_UAV(rdtest.TestCase): overlay_id = out.GetDebugOverlayTexID() - picked = self.controller.PickPixel(overlay_id, 5, 5, rd.Subresource(0,0,0), rd.CompType.Float).floatValue + picked = self.pick_pixel(overlay_id, 5, 5, rd.Subresource(0,0,0), rd.CompType.Float).floatValue if any([p != picked[0] for p in picked]): raise rdtest.TestFailureException(f"Quad overdraw isn't correct: {picked}") diff --git a/util/test/tests/GL/GL_Renderbuffer_Zoo.py b/util/test/tests/GL/GL_Renderbuffer_Zoo.py index 32ac2ef72..b2ad2ae7c 100644 --- a/util/test/tests/GL/GL_Renderbuffer_Zoo.py +++ b/util/test/tests/GL/GL_Renderbuffer_Zoo.py @@ -42,8 +42,9 @@ class GL_Renderbuffer_Zoo(rdtest.TestCase): rdtest.log.success(f'Color Renderbuffer at action {action.eventId} is working as expected') if depth.resource != rd.ResourceId(): - val = self.controller.PickPixel(depth.resource, x, y, - rd.Subresource(), rd.CompType.Typeless) + val = self.pick_pixel( + depth.resource, x, y, rd.Subresource(), rd.CompType.Typeless + ) if not rdtest.value_compare(val.floatValue[0], 0.75): raise rdtest.TestFailureException( diff --git a/util/test/tests/Vulkan/VK_Descriptor_Buffer.py b/util/test/tests/Vulkan/VK_Descriptor_Buffer.py index 61c4e4b98..68cb143eb 100644 --- a/util/test/tests/Vulkan/VK_Descriptor_Buffer.py +++ b/util/test/tests/Vulkan/VK_Descriptor_Buffer.py @@ -114,7 +114,7 @@ class VK_Descriptor_Buffer(rdtest.TestCase): floats = struct.unpack_from("8f", data, 0) - picked = self.controller.PickPixel( + picked = self.pick_pixel( out, x, y, rd.Subresource(), rd.CompType.Float ) diff --git a/util/test/tests/Vulkan/VK_Discard_Zoo.py b/util/test/tests/Vulkan/VK_Discard_Zoo.py index 6076c1bd4..9bd888e81 100644 --- a/util/test/tests/Vulkan/VK_Discard_Zoo.py +++ b/util/test/tests/Vulkan/VK_Discard_Zoo.py @@ -42,10 +42,10 @@ class VK_Discard_Zoo(rdtest.Discard_Zoo): # if we're in the rect, check for pattern colors if 50 <= x < 125 and 50 <= y < 125: - c = self.controller.PickPixel( + c = self.pick_pixel( rpcol.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) - d = self.controller.PickPixel( + d = self.pick_pixel( rpdepth.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) @@ -76,10 +76,10 @@ class VK_Discard_Zoo(rdtest.Discard_Zoo): # if we're in the rect, check for pattern colors if 50 <= x < 125 and 50 <= y < 125: - c = self.controller.PickPixel( + c = self.pick_pixel( rpcol.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) - d = self.controller.PickPixel( + d = self.pick_pixel( rpdepth.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) @@ -123,10 +123,10 @@ class VK_Discard_Zoo(rdtest.Discard_Zoo): # check that they are all undefined pattern - initial layout affects the whole resource for y in range(0, rpcol.height-1, 17): for x in range(0, rpcol.width - 1, 17): - c = self.controller.PickPixel( + c = self.pick_pixel( rpcol.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) - d = self.controller.PickPixel( + d = self.pick_pixel( rpdepth.resourceId, x, y, rd.Subresource(), rd.CompType.Typeless ) diff --git a/util/test/tests/Vulkan/VK_Indirect.py b/util/test/tests/Vulkan/VK_Indirect.py index c76b8f44a..366f4202f 100644 --- a/util/test/tests/Vulkan/VK_Indirect.py +++ b/util/test/tests/Vulkan/VK_Indirect.py @@ -112,7 +112,7 @@ class VK_Indirect(rdtest.TestCase): if overlay == rd.DebugOverlay.ClearBeforePass: overlayTex = col_tex - picked = self.controller.PickPixel(overlayTex, x, y, rd.Subresource(), rd.CompType.Typeless) + picked = self.pick_pixel(overlayTex, x, y, rd.Subresource(), rd.CompType.Typeless) out.Shutdown() return picked @@ -305,7 +305,7 @@ class VK_Indirect(rdtest.TestCase): for s in self.samples: x = s[0] y = s[1] - picked = self.controller.PickPixel(overlayTex, x, y, rd.Subresource(), rd.CompType.Typeless) + picked = self.pick_pixel(overlayTex, x, y, rd.Subresource(), rd.CompType.Typeless) if picked.floatValue != emptyPixel: empty = False if expectEmpty and not empty: diff --git a/util/test/tests/Vulkan/VK_Line_Raster.py b/util/test/tests/Vulkan/VK_Line_Raster.py index 3a87e0aae..fd33ccd25 100644 --- a/util/test/tests/Vulkan/VK_Line_Raster.py +++ b/util/test/tests/Vulkan/VK_Line_Raster.py @@ -23,7 +23,7 @@ class VK_Line_Raster(rdtest.TestCase): x = self.view[0] * col + p[0] y = self.view[1] * row + p[1] - picked = self.controller.PickPixel(self.tex, x, y, rd.Subresource(0, 0, 0), rd.CompType.Typeless) + picked = self.pick_pixel(self.tex, x, y, rd.Subresource(0, 0, 0), rd.CompType.Typeless) ret.append(rdtest.value_compare(picked.floatValue, [0.0, 1.0, 1.0, 1.0])) return ret diff --git a/util/test/tests/Vulkan/VK_VRS.py b/util/test/tests/Vulkan/VK_VRS.py index 157fe7698..c588a18d2 100644 --- a/util/test/tests/Vulkan/VK_VRS.py +++ b/util/test/tests/Vulkan/VK_VRS.py @@ -19,10 +19,10 @@ class VK_VRS(rdtest.TestCase): self.get_shading_rate_for_quad(tex, x + 74, y + 42)) def get_shading_rate_for_quad(self, tex: rd.ResourceId, x: int, y: int): - picked = [self.controller.PickPixel(tex, x+0, y+0, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+1, y+0, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+0, y+1, rd.Subresource(), rd.CompType.Typeless), - self.controller.PickPixel(tex, x+1, y+1, rd.Subresource(), rd.CompType.Typeless)] + picked = [self.pick_pixel(tex, x+0, y+0, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+1, y+0, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+0, y+1, rd.Subresource(), rd.CompType.Typeless), + self.pick_pixel(tex, x+1, y+1, rd.Subresource(), rd.CompType.Typeless)] # all same - 2x2 if all([p.floatValue == picked[0].floatValue for p in picked]):