56
56
}
57
57
58
58
#define CHECK_RENDERPASS \
59
- if (!((Pass *)render_pass)->in_progress) { \
59
+ if (!((RenderPass *)render_pass)->in_progress) { \
60
60
SDL_assert_release(!"Render pass not in progress!"); \
61
61
return; \
62
62
}
63
63
64
+ #define CHECK_SAMPLER_TEXTURES \
65
+ RenderPass *rp = (RenderPass *)render_pass; \
66
+ for (Uint32 color_target_index = 0; color_target_index < rp->num_color_targets; color_target_index += 1) { \
67
+ for (Uint32 texture_sampler_index = 0; texture_sampler_index < num_bindings; texture_sampler_index += 1) { \
68
+ if (rp->color_targets[color_target_index] == texture_sampler_bindings[texture_sampler_index].texture) { \
69
+ SDL_assert_release(!"Texture cannot be simultaneously bound as a color target and a sampler!"); \
70
+ } \
71
+ } \
72
+ } \
73
+ \
74
+ for (Uint32 texture_sampler_index = 0; texture_sampler_index < num_bindings; texture_sampler_index += 1) { \
75
+ if (rp->depth_stencil_target != NULL && rp->depth_stencil_target == texture_sampler_bindings[texture_sampler_index].texture) { \
76
+ SDL_assert_release(!"Texture cannot be simultaneously bound as a depth stencil target and a sampler!"); \
77
+ } \
78
+ }
79
+
80
+ #define CHECK_STORAGE_TEXTURES \
81
+ RenderPass *rp = (RenderPass *)render_pass; \
82
+ for (Uint32 color_target_index = 0; color_target_index < rp->num_color_targets; color_target_index += 1) { \
83
+ for (Uint32 texture_sampler_index = 0; texture_sampler_index < num_bindings; texture_sampler_index += 1) { \
84
+ if (rp->color_targets[color_target_index] == storage_textures[texture_sampler_index]) { \
85
+ SDL_assert_release(!"Texture cannot be simultaneously bound as a color target and a storage texture!"); \
86
+ } \
87
+ } \
88
+ } \
89
+ \
90
+ for (Uint32 texture_sampler_index = 0; texture_sampler_index < num_bindings; texture_sampler_index += 1) { \
91
+ if (rp->depth_stencil_target != NULL && rp->depth_stencil_target == storage_textures[texture_sampler_index]) { \
92
+ SDL_assert_release(!"Texture cannot be simultaneously bound as a depth stencil target and a storage texture!"); \
93
+ } \
94
+ }
95
+
64
96
#define CHECK_GRAPHICS_PIPELINE_BOUND \
65
97
if (!((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->graphics_pipeline_bound) { \
66
98
SDL_assert_release(!"Graphics pipeline not bound!"); \
137
169
((CommandBufferCommonHeader *)command_buffer)->device
138
170
139
171
#define RENDERPASS_COMMAND_BUFFER \
140
- ((Pass *)render_pass)->command_buffer
172
+ ((RenderPass *)render_pass)->command_buffer
141
173
142
174
#define RENDERPASS_DEVICE \
143
175
((CommandBufferCommonHeader *)RENDERPASS_COMMAND_BUFFER)->device
@@ -1544,6 +1576,13 @@ SDL_GPURenderPass *SDL_BeginGPURenderPass(
1544
1576
1545
1577
commandBufferHeader = (CommandBufferCommonHeader * )command_buffer ;
1546
1578
commandBufferHeader -> render_pass .in_progress = true;
1579
+ for (Uint32 i = 0 ; i < num_color_targets ; i += 1 ) {
1580
+ commandBufferHeader -> render_pass .color_targets [i ] = color_target_infos [i ].texture ;
1581
+ }
1582
+ commandBufferHeader -> render_pass .num_color_targets = num_color_targets ;
1583
+ if (depth_stencil_target_info != NULL ) {
1584
+ commandBufferHeader -> render_pass .depth_stencil_target = depth_stencil_target_info -> texture ;
1585
+ }
1547
1586
return (SDL_GPURenderPass * )& (commandBufferHeader -> render_pass );
1548
1587
}
1549
1588
@@ -1717,6 +1756,7 @@ void SDL_BindGPUVertexSamplers(
1717
1756
1718
1757
if (RENDERPASS_DEVICE -> debug_mode ) {
1719
1758
CHECK_RENDERPASS
1759
+ CHECK_SAMPLER_TEXTURES
1720
1760
}
1721
1761
1722
1762
RENDERPASS_DEVICE -> BindVertexSamplers (
@@ -1743,6 +1783,7 @@ void SDL_BindGPUVertexStorageTextures(
1743
1783
1744
1784
if (RENDERPASS_DEVICE -> debug_mode ) {
1745
1785
CHECK_RENDERPASS
1786
+ CHECK_STORAGE_TEXTURES
1746
1787
}
1747
1788
1748
1789
RENDERPASS_DEVICE -> BindVertexStorageTextures (
@@ -1795,6 +1836,7 @@ void SDL_BindGPUFragmentSamplers(
1795
1836
1796
1837
if (RENDERPASS_DEVICE -> debug_mode ) {
1797
1838
CHECK_RENDERPASS
1839
+ CHECK_SAMPLER_TEXTURES
1798
1840
}
1799
1841
1800
1842
RENDERPASS_DEVICE -> BindFragmentSamplers (
@@ -1821,6 +1863,7 @@ void SDL_BindGPUFragmentStorageTextures(
1821
1863
1822
1864
if (RENDERPASS_DEVICE -> debug_mode ) {
1823
1865
CHECK_RENDERPASS
1866
+ CHECK_STORAGE_TEXTURES
1824
1867
}
1825
1868
1826
1869
RENDERPASS_DEVICE -> BindFragmentStorageTextures (
@@ -1981,6 +2024,12 @@ void SDL_EndGPURenderPass(
1981
2024
1982
2025
commandBufferCommonHeader = (CommandBufferCommonHeader * )RENDERPASS_COMMAND_BUFFER ;
1983
2026
commandBufferCommonHeader -> render_pass .in_progress = false;
2027
+ for (Uint32 i = 0 ; i < MAX_COLOR_TARGET_BINDINGS ; i += 1 )
2028
+ {
2029
+ commandBufferCommonHeader -> render_pass .color_targets [i ] = NULL ;
2030
+ }
2031
+ commandBufferCommonHeader -> render_pass .num_color_targets = 0 ;
2032
+ commandBufferCommonHeader -> render_pass .depth_stencil_target = NULL ;
1984
2033
commandBufferCommonHeader -> graphics_pipeline_bound = false;
1985
2034
}
1986
2035
0 commit comments