@@ -52,6 +52,14 @@ public partial class CommandList : GraphicsResourceBase
5252 /// </summary>
5353 public int ViewportCount => boundViewportCount ;
5454
55+ /// <summary>
56+ /// Gets how draws access the currently bound Depth-Stencil Buffer.
57+ /// Part of the binding: reset to <see cref="DepthStencilAccess.Write"/> by any
58+ /// <c>SetRenderTargets</c> call.
59+ /// Stopgap until render pass objects declare this per pass.
60+ /// </summary>
61+ internal DepthStencilAccess DepthStencilAccess { get ; set ; }
62+
5563
5664 /// <summary>
5765 /// Binds a single viewport to the rasterizer stage of the pipeline.
@@ -238,6 +246,7 @@ public void ResetTargets()
238246 ResetTargetsImpl ( ) ;
239247
240248 depthStencilBuffer = null ;
249+ DepthStencilAccess = DepthStencilAccess . Write ;
241250 renderTargets . AsSpan ( ) . Clear ( ) ;
242251 }
243252
@@ -260,6 +269,7 @@ public void ResetTargets()
260269 public void SetRenderTargetAndViewport ( Texture depthStencilView , Texture renderTargetView )
261270 {
262271 depthStencilBuffer = depthStencilView ;
272+ DepthStencilAccess = DepthStencilAccess . Write ;
263273
264274 renderTargets [ 0 ] = renderTargetView ; // TODO: Should we clear the other entries?
265275 renderTargetCount = renderTargetView is not null ? 1 : 0 ;
@@ -286,6 +296,7 @@ public void SetRenderTargetAndViewport(Texture depthStencilView, Texture renderT
286296 public void SetRenderTargetsAndViewport ( ReadOnlySpan < Texture > renderTargetViews )
287297 {
288298 depthStencilBuffer = null ;
299+ DepthStencilAccess = DepthStencilAccess . Write ;
289300
290301 renderTargetCount = renderTargetViews . Length ;
291302 renderTargetViews . CopyTo ( renderTargets ) ;
@@ -315,6 +326,7 @@ public void SetRenderTargetsAndViewport(ReadOnlySpan<Texture> renderTargetViews)
315326 public void SetRenderTargetsAndViewport ( Texture depthStencilView , params ReadOnlySpan < Texture > renderTargetViews )
316327 {
317328 depthStencilBuffer = depthStencilView ;
329+ DepthStencilAccess = DepthStencilAccess . Write ;
318330
319331 renderTargetCount = renderTargetViews . Length ;
320332 renderTargetViews . CopyTo ( renderTargets ) ; // TODO: Should we clear the other entries?
@@ -340,6 +352,7 @@ public void SetRenderTargetsAndViewport(Texture depthStencilView, params ReadOnl
340352 public void SetRenderTarget ( Texture depthStencilView , Texture renderTargetView )
341353 {
342354 depthStencilBuffer = depthStencilView ;
355+ DepthStencilAccess = DepthStencilAccess . Write ;
343356
344357 renderTargetCount = renderTargetView is not null ? 1 : 0 ;
345358 renderTargets [ 0 ] = renderTargetView ; // TODO: Should we clear the other entries?
@@ -367,6 +380,7 @@ public void SetRenderTargets(ReadOnlySpan<Texture> renderTargetViews)
367380 ArgumentOutOfRangeException . ThrowIfGreaterThan ( renderTargetViews . Length , MaxRenderTargetCount ) ;
368381
369382 depthStencilBuffer = null ;
383+ DepthStencilAccess = DepthStencilAccess . Write ;
370384
371385 renderTargetCount = renderTargetViews . Length ;
372386 renderTargetViews . CopyTo ( renderTargets ) ; // TODO: Should we clear the other entries?
@@ -397,6 +411,7 @@ public void SetRenderTargets(Texture depthStencilView, params ReadOnlySpan<Textu
397411 ArgumentOutOfRangeException . ThrowIfGreaterThan ( renderTargetViews . Length , MaxRenderTargetCount ) ;
398412
399413 depthStencilBuffer = depthStencilView ;
414+ DepthStencilAccess = DepthStencilAccess . Write ;
400415
401416 renderTargetCount = renderTargetViews . Length ;
402417 renderTargetViews . CopyTo ( renderTargets ) ; // TODO: Should we clear the other entries?
@@ -482,6 +497,8 @@ public void ClearState()
482497 {
483498 ClearStateImpl ( ) ;
484499
500+ DepthStencilAccess = DepthStencilAccess . Write ;
501+
485502 // Setup empty viewports
486503 Array . Clear ( viewports ) ;
487504
0 commit comments