Harbor

Changelog fba2ff099dd1

centralize d3d12 transitions

@sky · 1 month ago · parent fb2aaa1365e6
0 added 4 modified 0 deleted
backend/d3d12/d3d12_backend.odin modified

Diff hidden because this file has more than 800 lines.

backend/d3d12/d3d12_frame.odin +4 -11 modified
153 unchanged lines hidden
154 154
155 155 // Transition backbuffer to PRESENT
156 156 bb := g_d3d.backbuffers[g_d3d.back_buffer_idx]
157 - transition_resource(bb, {.RENDER_TARGET}, d3d12.RESOURCE_STATE_PRESENT)
157 + transition_backbuffer_to_present_d3d12(bb)
158 158
159 159 // Close command list
160 160 result := g_d3d.command_list->Close()
74 unchanged lines hidden
235 235 continue
236 236 }
237 237 if tex_entry, tex_ok := texture_entry(color_tex); tex_ok && tex_entry.has_rtv {
238 - if tex_entry.state != {.RENDER_TARGET} {
239 - transition_resource(tex_entry.resource, tex_entry.state, {.RENDER_TARGET})
240 - tex_entry.state = {.RENDER_TARGET}
241 - }
238 + transition_texture_to_render_target_d3d12(tex_entry)
242 239 rtv_handles[rtv_count] = get_rtv_cpu_handle(tex_entry.rtv_index)
243 240 rtv_count += 1
244 241 }
4 unchanged lines hidden
249 246 has_dsv := false
250 247 if fb_entry.depth_tex != bk.NULL_TEXTURE {
251 248 if tex_entry, tex_ok := texture_entry(fb_entry.depth_tex); tex_ok && tex_entry.has_dsv {
252 - // Transition depth to DEPTH_WRITE
253 - if tex_entry.state != {.DEPTH_WRITE} {
254 - transition_resource(tex_entry.resource, tex_entry.state, {.DEPTH_WRITE})
255 - tex_entry.state = {.DEPTH_WRITE}
256 - }
249 + transition_texture_to_depth_write_d3d12(tex_entry)
257 250 dsv_handle = get_dsv_cpu_handle(tex_entry.dsv_index)
258 251 has_dsv = true
259 252 }
47 unchanged lines hidden
307 300
308 301 // Transition backbuffer to RENDER_TARGET
309 302 bb := g_d3d.backbuffers[g_d3d.back_buffer_idx]
310 - transition_resource(bb, d3d12.RESOURCE_STATE_PRESENT, {.RENDER_TARGET})
303 + transition_backbuffer_to_render_target_d3d12(bb)
311 304
312 305 // Get RTV for current backbuffer
313 306 rtv_handle := get_rtv_cpu_handle(g_d3d.back_buffer_idx)
82 unchanged lines hidden
backend/d3d12/d3d12_ops.odin modified

Diff hidden because this file has more than 800 lines.

scripts/check.sh +6 -0 modified
25 unchanged lines hidden
26 26 echo "==> test: tests"
27 27 odin test tests -collection:window="$WINDOW_COLLECTION"
28 28
29 + echo "==> check: d3d12 transition boundary"
30 + if grep -n "Type = \\.TRANSITION\\|transition_resource(" backend/d3d12/d3d12_ops.odin backend/d3d12/d3d12_frame.odin; then
31 + echo "D3D12 transition barriers must go through typed helpers in d3d12_backend.odin" >&2
32 + exit 1
33 + fi
34 +
29 35 for backend in vulkan d3d11 d3d12 opengl; do
30 36 echo "==> check: gpu ($backend)"
31 37 odin check . -no-entry-point -collection:window="$WINDOW_COLLECTION" -define:GPU_BACKEND="$backend"
15 unchanged lines hidden