示例#1
0
    def check_capture(self):
        self.controller.SetFrameEvent(0, False)

        pipe: rd.VKState = self.controller.GetVulkanPipelineState()

        # Check that the layout is reported correctly at the start of the frame
        for img in pipe.images:
            img: rd.VKImageData
            res = self.get_resource(img.resourceId)
            if res.name == "Image:Preinitialised":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_PREINITIALIZED":
                    raise rdtest.TestFailureException(
                        "Pre-initialised image is in {} layout".format(
                            img.layouts[0].name))
            elif res.name == "Image:Undefined":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_UNDEFINED":
                    raise rdtest.TestFailureException(
                        "Undefined image is in {} layout".format(
                            img.layouts[0].name))
            elif res.name == "Image:Swapchain":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_PRESENT_SRC_KHR":
                    raise rdtest.TestFailureException(
                        "Swapchain image is in {} layout".format(
                            img.layouts[0].name))

        action = self.find_action("Before Transition")

        self.check(action is not None)

        self.controller.SetFrameEvent(action.eventId, False)

        pipe: rd.VKState = self.controller.GetVulkanPipelineState()

        pre_init = rd.ResourceId()
        undef_img = rd.ResourceId()

        # Check that the layout is reported correctly before transitions still
        for img in pipe.images:
            img: rd.VKImageData
            res = self.get_resource(img.resourceId)
            if res.name == "Image:Preinitialised":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_PREINITIALIZED":
                    raise rdtest.TestFailureException(
                        "Pre-initialised image is in {} layout".format(
                            img.layouts[0].name))
                pre_init = img.resourceId
            elif res.name == "Image:Undefined":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_UNDEFINED":
                    raise rdtest.TestFailureException(
                        "Undefined image is in {} layout".format(
                            img.layouts[0].name))
                undef_img = img.resourceId
            elif res.name == "Image:Swapchain":
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_PRESENT_SRC_KHR":
                    raise rdtest.TestFailureException(
                        "Swapchain image is in {} layout".format(
                            img.layouts[0].name))

        action = self.find_action("vkCmdDraw")

        self.check(action is not None)

        self.controller.SetFrameEvent(action.eventId, False)

        # Check that the backbuffer didn't get discarded
        self.check_triangle(out=action.outputs[0])

        col = [float(0x40) / 255.0] * 4

        # The pre-initialised image should have the correct data still also
        self.check_triangle(out=pre_init, back=col, fore=col)

        # we copied its contents into the undefined image so it should also have the right colour
        self.check_triangle(out=undef_img, back=col, fore=col)

        pipe: rd.VKState = self.controller.GetVulkanPipelineState()

        # Check that after transitions, the images are in the right state
        for img in pipe.images:
            img: rd.VKImageData
            res = self.get_resource(img.resourceId)
            if res.name == "Image:Preinitialised":
                if img.layouts[
                        0].name != "VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL":
                    raise rdtest.TestFailureException(
                        "Pre-initialised image is in {} layout".format(
                            img.layouts[0].name))
            elif res.name == "Image:Undefined":
                if img.layouts[
                        0].name != "VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL":
                    raise rdtest.TestFailureException(
                        "Undefined image is in {} layout".format(
                            img.layouts[0].name))
            elif img.resourceId == pipe.currentPass.framebuffer.attachments[
                    0].imageResourceId:
                if img.layouts[0].name != "VK_IMAGE_LAYOUT_GENERAL":
                    raise rdtest.TestFailureException(
                        "Rendered swapchain image is in {} layout".format(
                            img.layouts[0].name))
示例#2
0
    def check_capture(self):
        action: rd.ActionDescription = self.find_action('glDraw')

        while action is not None:
            self.controller.SetFrameEvent(action.eventId, True)

            self.check_triangle(fore=[0.2, 0.75, 0.2, 1.0])

            pipe = self.controller.GetPipelineState()
            depth = pipe.GetDepthTarget()
            vp = pipe.GetViewport(0)

            id = pipe.GetOutputTargets()[0].resourceId

            mn, mx = self.controller.GetMinMax(id, rd.Subresource(), rd.CompType.Typeless)

            if not rdtest.value_compare(mn.floatValue, [0.2, 0.2, 0.2, 1.0], eps=1.0/255.0):
                raise rdtest.TestFailureException(
                    "Minimum color values {} are not as expected".format(mn.floatValue))

            if not rdtest.value_compare(mx.floatValue, [0.2, 0.75, 0.2, 1.0], eps=1.0/255.0):
                raise rdtest.TestFailureException(
                    "Maximum color values {} are not as expected".format(mx.floatValue))

            hist = self.controller.GetHistogram(id, rd.Subresource(), rd.CompType.Typeless, 0.199, 0.75,
                                                (False, True, False, False))

            if hist[0] == 0 or hist[-1] == 0 or any([x > 0 for x in hist[1:-1]]):
                raise rdtest.TestFailureException(
                    "Green histogram didn't return expected values, values should have landed in first or last bucket")

            rdtest.log.success('Color Renderbuffer at action {} is working as expected'.format(action.eventId))

            if depth.resourceId != rd.ResourceId():
                val = self.controller.PickPixel(depth.resourceId, int(0.5 * vp.width), int(0.5 * vp.height),
                                                rd.Subresource(), rd.CompType.Typeless)

                if not rdtest.value_compare(val.floatValue[0], 0.75):
                    raise rdtest.TestFailureException(
                        "Picked value {} in triangle for depth doesn't match expectation".format(val))

                mn, mx = self.controller.GetMinMax(depth.resourceId, rd.Subresource(), rd.CompType.Typeless)
                hist = self.controller.GetHistogram(depth.resourceId, rd.Subresource(),
                                                    rd.CompType.Typeless, 0.75, 0.9, (True, False, False, False))

                if not rdtest.value_compare(mn.floatValue[0], 0.75):
                    raise rdtest.TestFailureException(
                        "Minimum depth values {} are not as expected".format(mn.floatValue))

                if not rdtest.value_compare(mx.floatValue[0], 0.9):
                    raise rdtest.TestFailureException(
                        "Maximum depth values {} are not as expected".format(mx.floatValue))

                if hist[0] == 0 or hist[-1] == 0 or any([x > 0 for x in hist[1:-1]]):
                    raise rdtest.TestFailureException(
                        "Depth histogram didn't return expected values, values should have landed in first or last bucket")

                rdtest.log.success('Depth Renderbuffer at action {} is working as expected'.format(action.eventId))

            tex_details = self.get_texture(id)

            if tex_details.msSamp > 1:
                samples = []
                for i in range(tex_details.msSamp):
                    samples.append(self.controller.GetTextureData(id, rd.Subresource(0, 0, i)))

                for i in range(tex_details.msSamp):
                    for j in range(tex_details.msSamp):
                        if i == j:
                            continue

                        if samples[i] == samples[j]:
                            save_data = rd.TextureSave()
                            save_data.resourceId = id
                            save_data.destType = rd.FileType.PNG
                            save_data.slice.sliceIndex = 0
                            save_data.mip = 0

                            img_path0 = rdtest.get_tmp_path('sample{}.png'.format(i))
                            img_path1 = rdtest.get_tmp_path('sample{}.png'.format(j))

                            save_data.sample.sampleIndex = i
                            self.controller.SaveTexture(save_data, img_path0)
                            save_data.sample.sampleIndex = j
                            self.controller.SaveTexture(save_data, img_path1)

                            raise rdtest.TestFailureException("Two MSAA samples returned the same data", img_path0, img_path1)

            action: rd.ActionDescription = self.find_action('glDraw', action.eventId+1)

        rdtest.log.success('All renderbuffers checked and rendered correctly')
示例#3
0
    def check_capture(self):
        action = self.get_last_action()

        self.controller.SetFrameEvent(action.eventId, False)

        # Should have barycentrics showing the closest vertex for each pixel in the triangle
        # Without relying on barycentric order, ensure that the three pixels are red, green, and blue
        pixels = []

        picked: rd.PixelValue = self.controller.PickPixel(
            action.copyDestination, 125, 215, rd.Subresource(),
            rd.CompType.UNorm)
        pixels.append(picked.floatValue[0:4])
        picked: rd.PixelValue = self.controller.PickPixel(
            action.copyDestination, 200, 85, rd.Subresource(),
            rd.CompType.UNorm)
        pixels.append(picked.floatValue[0:4])
        picked: rd.PixelValue = self.controller.PickPixel(
            action.copyDestination, 285, 215, 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 (
                    not (1.0, 0.0, 0.0, 1.0) in pixels):
            raise rdtest.TestFailureException(
                "Expected red, green and blue in picked pixels. Got {}".format(
                    pixels))

        rdtest.log.success("Picked barycentric values are as expected")

        # find the cpuMax and gpuMax actions
        cpuMax = self.find_action("cpuMax")
        gpuMax = self.find_action("gpuMax")

        # The values should be identical
        cpuMax = int(cpuMax.customName[8:])
        gpuMax = int(gpuMax.customName[8:])

        if cpuMax != gpuMax or cpuMax == 0:
            raise rdtest.TestFailureException(
                "captured cpuMax and gpuMax are not equal and positive: {} vs {}"
                .format(cpuMax, gpuMax))

        rdtest.log.success("recorded cpuMax and gpuMax are as expected")

        outBuf = self.get_resource_by_name("outBuf")

        data = self.controller.GetBufferData(outBuf.resourceId, 0, 8)

        replayedGpuMax = struct.unpack("Q", data)[0]

        if replayedGpuMax != gpuMax:
            raise rdtest.TestFailureException(
                "captured gpuMax and replayed gpuMax are not equal: {} vs {}".
                format(gpuMax, replayedGpuMax))

        rdtest.log.success("replayed gpuMax is as expected")

        cs = self.get_resource_by_name("cs")
        pipe = rd.ResourceId()

        refl: rd.ShaderReflection = self.controller.GetShader(
            pipe, cs.resourceId,
            rd.ShaderEntryPoint("main", rd.ShaderStage.Compute))

        self.check(len(refl.readWriteResources) == 2)
        self.check([rw.name
                    for rw in refl.readWriteResources] == ["inUAV", "outUAV"])

        disasm = self.controller.DisassembleShader(pipe, refl, "")

        if "amd_u64_atomic" not in disasm:
            raise rdtest.TestFailureException(
                "Didn't find expected AMD opcode in disassembly: {}".format(
                    disasm))

        rdtest.log.success("compute shader disassembly is as expected")

        if refl.debugInfo.debuggable:
            self.controller.SetFrameEvent(
                self.find_action("Dispatch").eventId, False)

            trace: rd.ShaderDebugTrace = self.controller.DebugThread((0, 0, 0),
                                                                     (0, 0, 0))

            if trace.debugger is None:
                self.controller.FreeTrace(trace)

                raise rdtest.TestFailureException(
                    "Couldn't debug compute shader")

            cycles, variables = self.process_trace(trace)

            if cycles < 3:
                raise rdtest.TestFailureException(
                    "Compute shader has too few cycles {}".format(cycles))
        else:
            raise rdtest.TestFailureException(
                "Compute shader is listed as non-debuggable: {}".format(
                    refl.debugInfo.debugStatus))

        rdtest.log.success("compute shader debugged successfully")
示例#4
0
    def check_capture(self):
        for pass_type in ["SM50", "SM51", "SM60"]:
            draw = self.find_draw(pass_type + " Draw")

            if draw is not None:
                self.controller.SetFrameEvent(draw.next.eventId, False)

                pipe = self.controller.GetPipelineState()
                tex = pipe.GetOutputTargets()[0].resourceId
                vp = pipe.GetViewport(0)

                # Should have barycentrics showing the closest vertex for each pixel in the triangle
                # Without relying on barycentric order, ensure that the three pixels are red, green, and blue
                pixels = []

                x = int(vp.x + vp.width * 0.5)
                y = int(vp.y + vp.height * 0.5)

                picked: rd.PixelValue = self.controller.PickPixel(
                    tex, x + 0, y + 0, rd.Subresource(), rd.CompType.UNorm)
                pixels.append(picked.floatValue[0:4])
                picked: rd.PixelValue = self.controller.PickPixel(
                    tex, x - 20, y + 20, rd.Subresource(), rd.CompType.UNorm)
                pixels.append(picked.floatValue[0:4])
                picked: rd.PixelValue = self.controller.PickPixel(
                    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 (
                            not (1.0, 0.0, 0.0, 1.0) in pixels):
                    raise rdtest.TestFailureException(
                        "Expected red, green and blue in picked pixels. Got {}"
                        .format(pixels))

                rdtest.log.success("Picked barycentric values are as expected")

                draw = self.find_draw(pass_type + " Dispatch")

                self.controller.SetFrameEvent(draw.next.eventId, False)

                # find the cpuMax and gpuMax draws
                cpuMax = self.find_draw(pass_type + " cpuMax")
                gpuMax = self.find_draw(pass_type + " gpuMax")

                # The values should be identical
                cpuMax = int(cpuMax.name.split(': ')[1])
                gpuMax = int(gpuMax.name.split(': ')[1])

                if cpuMax != gpuMax or cpuMax == 0:
                    raise rdtest.TestFailureException(
                        "captured cpuMax and gpuMax are not equal and positive: {} vs {}"
                        .format(cpuMax, gpuMax))

                rdtest.log.success(
                    "recorded cpuMax and gpuMax are as expected")

                outBuf = self.get_resource_by_name("outBuf")

                data = self.controller.GetBufferData(outBuf.resourceId, 0, 8)

                replayedGpuMax = struct.unpack("Q", data)[0]

                if replayedGpuMax != gpuMax:
                    raise rdtest.TestFailureException(
                        "captured gpuMax and replayed gpuMax are not equal: {} vs {}"
                        .format(gpuMax, replayedGpuMax))

                rdtest.log.success("replayed gpuMax is as expected")
            # We should get everything except maybe DXIL
            elif pass_type != "SM60":
                raise rdtest.TestFailureException(
                    "Didn't find test draw for {}".format(pass_type))

            # We always check the CS pipe to ensure the reflection is OK
            cs_pipe = self.get_resource_by_name("cspipe" + pass_type)

            if cs_pipe is None:
                # everything but DXIL we must get, DXIL we may not be able to compile
                if pass_type != "SM60":
                    raise rdtest.TestFailureException(
                        "Didn't find compute pipeline for {}".format(
                            pass_type))
                continue

            pipe = cs_pipe.resourceId
            cs = rd.ResourceId()

            for d in cs_pipe.derivedResources + cs_pipe.parentResources:
                res = self.get_resource(d)
                if res.type == rd.ResourceType.Shader:
                    cs = res.resourceId
                    break

            refl: rd.ShaderReflection = self.controller.GetShader(
                pipe, cs, rd.ShaderEntryPoint("main", rd.ShaderStage.Compute))

            self.check(len(refl.readWriteResources) == 2)
            self.check(
                [rw.name
                 for rw in refl.readWriteResources] == ["inUAV", "outUAV"])

            # Don't test disassembly or debugging with DXIL, we don't do any of that
            if pass_type == "SM60":
                continue

            disasm = self.controller.DisassembleShader(pipe, refl, "")

            if "amd_u64_atomic" not in disasm:
                raise rdtest.TestFailureException(
                    "Didn't find expected AMD opcode in disassembly: {}".
                    format(disasm))

            rdtest.log.success("compute shader disassembly is as expected")

            if refl.debugInfo.debuggable:
                self.controller.SetFrameEvent(
                    self.find_draw("Dispatch").eventId, False)

                trace: rd.ShaderDebugTrace = self.controller.DebugThread(
                    (0, 0, 0), (0, 0, 0))

                if trace.debugger is None:
                    self.controller.FreeTrace(trace)

                    raise rdtest.TestFailureException(
                        "Couldn't debug compute shader")

                cycles, variables = self.process_trace(trace)

                if cycles < 3:
                    raise rdtest.TestFailureException(
                        "Compute shader has too few cycles {}".format(cycles))
            else:
                raise rdtest.TestFailureException(
                    "Compute shader is listed as non-debuggable: {}".format(
                        refl.debugInfo.debugStatus))

            rdtest.log.success("compute shader debugged successfully")