Skip to content

Commit

Permalink
Fix "Texture 'RenderWindow DepthBuffer' is TilerMemoryless" for all s…
Browse files Browse the repository at this point in the history
…amples
  • Loading branch information
darksylinc committed Dec 5, 2024
1 parent ec8a981 commit 49400b0
Show file tree
Hide file tree
Showing 16 changed files with 218 additions and 23 deletions.
15 changes: 15 additions & 0 deletions OgreMain/src/Compositor/Pass/OgreCompositorPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,21 @@ namespace Ogre
rtv->preferDepthTexture, rtv->depthBufferFormat );
}

if( mDefinition->mSkipLoadStoreSemantics )
{
// Set everything to dont_care since validation must not complain.
const size_t numColourEntries = renderPassDesc->getNumColourEntries();
for( size_t i = 0u; i < numColourEntries; ++i )
{
renderPassDesc->mColour[i].loadAction = LoadAction::DontCare;
renderPassDesc->mColour[i].storeAction = StoreAction::DontCare;
}
renderPassDesc->mDepth.loadAction = LoadAction::DontCare;
renderPassDesc->mDepth.storeAction = StoreAction::DontCare;
renderPassDesc->mStencil.loadAction = LoadAction::DontCare;
renderPassDesc->mStencil.storeAction = StoreAction::DontCare;
}

postRenderPassDescriptorSetup( renderPassDesc );

try
Expand Down
7 changes: 7 additions & 0 deletions Samples/2.0/ApiUsage/StereoRendering/StereoRendering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ namespace Demo
return mEyeWorkspaces[0];
}

void initMiscParamsListener( Ogre::NameValuePairList &params ) override
{
// This sample specifically REQUIRES the window's depth buffer contents to be preserved
// between multiple passes. Therefore we must disable it.
params["memoryless_depth_buffer"] = "No";
}

public:
StereoGraphicsSystem( GameState *gameState ) : GraphicsSystem( gameState ) {}
};
Expand Down
4 changes: 2 additions & 2 deletions Samples/2.0/Common/src/System/Desktop/UnitTesting.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -692,10 +692,10 @@ namespace Demo
img.save( outputFolder + frameIdxStr + "RenderWindow_colour.png", 0u,
texture->getNumMipmaps() );

texture = renderWindow->getDepthBuffer();
/*texture = renderWindow->getDepthBuffer();
img.convertFromTexture( texture, 0u, texture->getNumMipmaps() - 1u );
img.save( outputFolder + frameIdxStr + "RenderWindow_depth.exr", 0u,
texture->getNumMipmaps() );
texture->getNumMipmaps() );*/
}

Ogre::StringVector::const_iterator itor =
Expand Down
5 changes: 5 additions & 0 deletions Samples/Media/2.0/scripts/Compositors/Refractions.compositor
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,11 @@ compositor_node RefractionsRefractionsNode
pass render_quad
{
load { all dont_care }
store
{
depth dont_care
stencil dont_care
}
material Ogre/Copy/4xFP32
input 0 rtt_final

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ compositor_node TutorialSky_PostprocessRenderingNode
all clear
clear_colour 0.2 0.4 0.6 1
}
store
{
depth dont_care
stencil dont_care
}
overlays off
rq_first 0
rq_last 2
Expand All @@ -22,6 +27,8 @@ compositor_node TutorialSky_PostprocessRenderingNode
//Render sky after opaque stuff (performance optimization)
pass render_quad
{
skip_load_store_semantics true

quad_normals camera_direction
material SkyPostprocess

Expand All @@ -31,11 +38,37 @@ compositor_node TutorialSky_PostprocessRenderingNode
//Render transparent stuff after sky
pass render_scene
{
skip_load_store_semantics true

overlays on
rq_first 2

profiling_id "Transparents"
}


// Render overlays.
pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
stencil dont_care
}

overlays on
rq_first 254
rq_last 255

profiling_id "Overlays"
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,18 +127,24 @@ compositor_node Tutorial_DynamicCubemapRenderingNode
//Render sky (see TutorialSky_Postprocess)
pass render_quad
{
store
{
depth dont_care
stencil dont_care
}
skip_load_store_semantics true

quad_normals camera_direction
material SkyPostprocess

profiling_id "Sky"
}

//Render transparent stuff after sky
pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,15 @@ compositor_node Tutorial_ReconstructPosFromDepthNode
{
load
{
colour dont_care
colour dont_care
depth dont_care
stencil dont_care
}

store
{
depth dont_care
stencil dont_care
}

material ReconstructPosFromDepth
Expand All @@ -50,6 +58,13 @@ compositor_node Tutorial_ReconstructPosFromDepthNode

pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@ compositor_node Tutorial_TerrainRenderingNode

target rt_renderwindow
{
pass clear
{
colour_value 0.2 0.4 0.6 1
}

pass render_scene
{
load
Expand Down
7 changes: 7 additions & 0 deletions Samples/Media/2.0/scripts/Compositors/UvBaking.compositor
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ compositor_node ShowBakingTextureNode

pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ compositor_node DistortionNode
{
all dont_care
}
store
{
depth dont_care
stencil dont_care
}
material Distortion/Quad
input 0 rt_scene
input 1 rt_distortion
Expand All @@ -71,6 +76,19 @@ compositor_node DistortionNode
{
lod_update_list off

// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
stencil dont_care
}

//Render Overlays
overlays on
rq_first 254
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,11 @@ compositor_node FinalComposition
pass render_quad
{
load { all dont_care }
store
{
depth dont_care
stencil dont_care
}
//Ignore the alpha channel
material Ogre/Copy/4xFP32
input 0 rtN
Expand All @@ -537,6 +542,19 @@ compositor_node FinalComposition

// skip_load_store_semantics true

// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
stencil dont_care
}

lod_update_list off

//Render Overlays
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,21 +18,38 @@ compositor_node TutorialComputeTest01_UavTextureRenderingNode

target rt_renderwindow
{
pass clear
{
colour_value 0.2 0.4 0.6 1
}

//Compositor will issue the appropiate barriers because
//it knows testTexture will be used as a texture.
pass render_quad
{
load
{
all dont_care
}
store
{
depth dont_care
stencil dont_care
}

material Ogre/Copy/4xFP32
input 0 testTexture
}

pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
stencil dont_care
}
overlays on
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ compositor_node TutorialComputeTest02_UavBufferRenderingNode

target rt_renderwindow
{
pass clear
{
colour_value 0.2 0.4 0.6 1
}

//The bindings made by pass bind_uav PERSIST even after we're out of rt_renderwindow.
pass bind_uav
{
load
{
all dont_care
}
store
{
depth dont_care
stencil dont_care
}

starting_slot 1
uav_buffer 0 testBuffer read
}
Expand All @@ -36,12 +41,35 @@ compositor_node TutorialComputeTest02_UavBufferRenderingNode
//it knows testTexture will be used as a texture.
pass render_quad
{
load
{
all dont_care
}
store
{
depth dont_care
stencil dont_care
}

material DrawFromUavBuffer
uses_uav 0 read
}

pass render_scene
{
// We must set depth & stencil to dont_care because the
// Window's DepthBuffer is Memoryless by default and Overlays break the pass.
load
{
depth dont_care
stencil dont_care
}
store
{
depth dont_care
stencil dont_care
}

overlays on
}
}
Expand Down
Loading

0 comments on commit 49400b0

Please sign in to comment.