Repository navigation
Expand file tree
/
Copy pathpipe_state.py
More file actions
133 lines (109 loc) · 4.21 KB
/
Copy pathpipe_state.py
File metadata and controls
133 lines (109 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# these imports are not strictly necessary, but are convenient
import renderdoc
import qrenderdoc
# this is here to give autocomplete when editing the example
# in VS Code where it doesn't know about this global
from typing import TYPE_CHECKING
if TYPE_CHECKING:
pyrenderdoc = qrenderdoc.CaptureContext()
if not pyrenderdoc.IsCaptureLoaded():
filename = pyrenderdoc.Extensions().OpenFileName("Choose a capture", "", "*.rdc")
pyrenderdoc.LoadCapture(filename, renderdoc.ReplayOptions(), filename, False, True)
pipe = pyrenderdoc.CurPipelineState()
get_name = lambda id: pyrenderdoc.GetResourceName(id)
print("-------------------------")
print(" Outputs ")
print("-------------------------")
# list all the output targets
outs = pipe.GetOutputTargets()
for i, out in enumerate(outs):
id = out.resource
# ignore any targets that are unbound
if id != renderdoc.ResourceId():
print(f"Out {i}: {get_name(id)}")
id = pipe.GetDepthTarget().resource
print(f"Depth: {get_name(id)}")
print()
print("-------------------------")
print(" Pipeline/Shaders ")
print("-------------------------")
id = pipe.GetGraphicsPipelineObject()
print(f"Pipeline: {get_name(id)}")
id = pipe.GetShader(renderdoc.ShaderStage.Vertex)
print(f"VS: {get_name(id)}")
id = pipe.GetShader(renderdoc.ShaderStage.Pixel)
print(f"PS: {get_name(id)}")
print()
print("-------------------------")
print(" Constant Blocks (VS) ")
print("-------------------------")
cbs = pipe.GetConstantBlocks(renderdoc.ShaderStage.Vertex)
# print out the stage even though we've asked for vertex CBs.
# the index corresponds to which constant block in the vertex
# reflection was used (omitted here is the array index which
# doesn't affect that lookup)
for cb in cbs:
print(
f"{str(cb.access.stage)} CB[{cb.access.index}]: {get_name(cb.descriptor.resource)}"
)
print()
print("-------------------------")
print(" Descriptors by Stage ")
print("-------------------------")
# ask for all descriptors but only those that are used
descs = pipe.GetAllUsedDescriptors(True)
# first we'll iterate over all possible shader stages, and get all
# the descriptors for that stage
for stage in renderdoc.ShaderStage:
# silently skip stages with no used bindings
stage_descs = [d for d in descs if d.access.stage == stage]
if stage_descs == []:
continue
# now iterate over the descriptors and print its type and the resources
# in the descriptor
print(f"** {str(stage)} descriptors:")
for d in stage_descs:
desc_str = f"{str(d.access.type)} - "
if (
d.sampler.object != renderdoc.ResourceId()
and d.descriptor.resource != renderdoc.ResourceId()
):
desc_str += (
f"{get_name(d.descriptor.resource)} + {get_name(d.sampler.object)}"
)
elif d.sampler.object != renderdoc.ResourceId():
desc_str += f"{get_name(d.sampler.object)}"
else:
desc_str += f"{get_name(d.descriptor.resource)}"
print(desc_str)
# we also print the descriptor store this is stored in
print(
f" in {get_name(d.access.descriptorStore)} at offset {d.access.byteOffset}"
)
print()
print("-------------------------")
print(" Descriptors by Type ")
print("-------------------------")
# Iterate in a similar way, but this time grouping by descriptor type
for desctype in renderdoc.DescriptorType:
type_descs = [d for d in descs if d.access.type == desctype]
if type_descs == []:
continue
print(f"** {str(desctype)} descriptors:")
for d in type_descs:
desc_str = f"{str(d.access.stage)} - "
if (
d.sampler.object != renderdoc.ResourceId()
and d.descriptor.resource != renderdoc.ResourceId()
):
desc_str += (
f"{get_name(d.descriptor.resource)} + {get_name(d.sampler.object)}"
)
elif d.sampler.object != renderdoc.ResourceId():
desc_str += f"{get_name(d.sampler.object)}"
else:
desc_str += f"{get_name(d.descriptor.resource)}"
print(desc_str)
print(
f" in {get_name(d.access.descriptorStore)} at offset {d.access.byteOffset}"
)