mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-09-15 10:15:48 +00:00
Add a helper and context for tracking the last pixel pick
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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])
|
||||
|
||||
@@ -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 (
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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]):
|
||||
|
||||
@@ -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}")
|
||||
|
||||
@@ -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(
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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]):
|
||||
|
||||
Reference in New Issue
Block a user