Another MSAA error, this time with Direct3D Topic is solved

Discussion area about developing with Ogre-Next (2.1, 2.2 and beyond)


jwwalker
Goblin
Posts: 285
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 21

Another MSAA error, this time with Direct3D

Post by jwwalker »

After some struggles described in another thread, I got my program doing MSAA on Mac with Metal. But when I try it on Windows (32-bit) with the Direct3D11 rendering system, I get an exception. Here's Ogre.log:

Code: Select all

14:01:29: Creating resource group General
14:01:29: Creating resource group Internal
14:01:29: Creating resource group Autodetect
14:01:29: SceneManagerFactory for type 'DefaultSceneManager' registered.
14:01:29: Registering ResourceManager for type Material
14:01:29: Registering ResourceManager for type Mesh
14:01:29: Registering ResourceManager for type Mesh2
14:01:29: Registering ResourceManager for type OldSkeleton
14:01:29: MovableObjectFactory for type 'ParticleSystem' registered.
14:01:29: ArchiveFactory for archive type FileSystem registered.
14:01:29: ArchiveFactory for archive type Zip registered.
14:01:29: ArchiveFactory for archive type EmbeddedZip registered.
14:01:29: DDS codec registering
14:01:29: FreeImage version: 3.18.0
14:01:29: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
14:01:29: Supported formats: bmp,ico,jpg,jif,jpeg,jpe,jng,koa,iff,lbm,mng,pbm,pbm,pcd,pcx,pgm,pgm,png,ppm,ppm,ras,tga,targa,tif,tiff,wap,wbmp,wbm,psd,psb,cut,xbm,xpm,gif,hdr,g3,sgi,rgb,rgba,bw,exr,j2k,j2c,jp2,pfm,pct,pict,pic,3fr,arw,bay,bmq,cap,cine,cr2,crw,cs1,dc2,dcr,drf,dsc,dng,erf,fff,ia,iiq,k25,kc2,kdc,mdc,mef,mos,mrw,nef,nrw,orf,pef,ptx,pxn,qtk,raf,raw,rdc,rw2,rwl,rwz,sr2,srf,srw,sti,x3f,webp,jxr,wdp,hdp
14:01:29: OITD codec registering
14:01:29: Registering ResourceManager for type HighLevelGpuProgram
14:01:29: MovableObjectFactory for type 'Decal' registered.
14:01:29: MovableObjectFactory for type 'InternalCubemapProbe' registered.
14:01:29: MovableObjectFactory for type 'Entity' registered.
14:01:29: MovableObjectFactory for type 'Item' registered.
14:01:29: MovableObjectFactory for type 'Light' registered.
14:01:29: MovableObjectFactory for type 'ParticleSystem2' registered.
14:01:29: MovableObjectFactory for type 'Rectangle2Dv2' registered.
14:01:29: MovableObjectFactory for type 'BillboardSet' registered.
14:01:29: MovableObjectFactory for type 'ManualObject2' registered.
14:01:29: MovableObjectFactory for type 'BillboardChain' registered.
14:01:29: MovableObjectFactory for type 'RibbonTrail' registered.
14:01:29: MovableObjectFactory for type 'WireAabb' registered.
14:01:29: *-*-* OGRE Initialising
14:01:29: *-*-* Version 4.0.0unstable (F)
14:01:29: Loading library D:\FFx32\RenderSystem_Direct3D11_d.dll
14:01:29: Installing plugin: D3D11 RenderSystem
14:01:29: D3D11: Direct3D11 Rendering Subsystem created.
14:01:29: D3D11: Driver Detection Starts
14:01:29: D3D11: "NVIDIA GeForce RTX 2060"
14:01:29: D3D11: "Microsoft Basic Render Driver (software)"
14:01:29: D3D11: Driver Detection Ends
14:01:29: Plugin successfully installed
14:01:29: D3D11: RenderSystem Option: sRGB Gamma Conversion = Yes
14:01:29: CPU Identifier & Features
14:01:29: -------------------------
14:01:29:  *   CPU ID: GenuineIntel: Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
14:01:29:  *   Logical cores: 8
14:01:29:  *      SSE: yes
14:01:29:  *     SSE2: yes
14:01:29:  *     SSE3: yes
14:01:29:  *      MMX: yes
14:01:29:  *   MMXEXT: yes
14:01:29:  *    3DNOW: no
14:01:29:  * 3DNOWEXT: no
14:01:29:  *     CMOV: yes
14:01:29:  *      TSC: yes
14:01:29:  *      FPU: yes
14:01:29:  *      PRO: yes
14:01:29:  *       HT: no
14:01:29: -------------------------
14:01:29: D3D11: Subsystem Initialising
14:01:29: D3D11: Driver Detection Starts
14:01:29: D3D11: "NVIDIA GeForce RTX 2060"
14:01:29: D3D11: "Microsoft Basic Render Driver (software)"
14:01:29: D3D11: Driver Detection Ends
14:01:29: D3D11: Requested "(default)", selected "NVIDIA GeForce RTX 2060"
14:01:29: D3D11: Device Feature Level 11.1
14:01:29: ***************************************
14:01:29: *** D3D11: Subsystem Initialized OK ***
14:01:29: ***************************************
14:01:29: D3D11RenderSystem::_createRenderWindow "temp", 400x300 windowed  miscParams: externalWindowHandle=263872 outerDimensions=true 
14:01:29: Registering ResourceManager for type GpuProgram
14:01:29: RenderSystem capabilities
14:01:29: -------------------------
14:01:29: RenderSystem Name: Direct3D11 Rendering Subsystem
14:01:29: GPU Vendor: nvidia
14:01:29: Device Name: NVIDIA GeForce RTX 2060
14:01:29: Driver Version: 32.0.15.7652
14:01:29:  * Fixed function pipeline: no
14:01:29:  * Hardware generation of mipmaps: yes
14:01:29:  * Texture blending: yes
14:01:29:  * Anisotropic texture filtering: yes
14:01:29:  * Dot product texture operation: yes
14:01:29:  * Cube mapping: yes
14:01:29:  * Hardware stencil buffer: yes
14:01:29:    - Stencil depth: 8
14:01:29:    - Two sided stencil support: yes
14:01:29:    - Wrap stencil values: yes
14:01:29:  * Hardware vertex / index buffers: yes
14:01:29:  * 32-bit index buffers: yes
14:01:29:  * Vertex programs: yes
14:01:29:  * Number of floating-point constants for vertex programs: 512
14:01:29:  * Number of integer constants for vertex programs: 16
14:01:29:  * Number of boolean constants for vertex programs: 16
14:01:29:  * Fragment programs: yes
14:01:29:  * Number of floating-point constants for fragment programs: 512
14:01:29:  * Number of integer constants for fragment programs: 16
14:01:29:  * Number of boolean constants for fragment programs: 16
14:01:29:  * Geometry programs: yes
14:01:29:  * Number of floating-point constants for geometry programs: 512
14:01:29:  * Number of integer constants for geometry programs: 16
14:01:29:  * Number of boolean constants for geometry programs: 16
14:01:29:  * Tessellation Hull programs: yes
14:01:29:  * Number of floating-point constants for tessellation hull programs: 512
14:01:29:  * Number of integer constants for tessellation hull programs: 16
14:01:29:  * Number of boolean constants for tessellation hull programs: 16
14:01:29:  * Tessellation Domain programs: yes
14:01:29:  * Number of floating-point constants for tessellation domain programs: 512
14:01:29:  * Number of integer constants for tessellation domain programs: 16
14:01:29:  * Number of boolean constants for tessellation domain programs: 16
14:01:29:  * Compute programs: yes
14:01:29:  * Number of floating-point constants for compute programs: 512
14:01:29:  * Number of integer constants for compute programs: 16
14:01:29:  * Number of boolean constants for compute programs: 16
14:01:29:  * Supported Shader Profiles: cs_5_0 ds_5_0 gs_4_0 gs_4_1 gs_5_0 hlsl hs_5_0 ps_4_0 ps_4_0_level_9_1 ps_4_0_level_9_3 ps_4_1 ps_5_0 vs_4_0 vs_4_0_level_9_1 vs_4_0_level_9_3 vs_4_1 vs_5_0
14:01:29:  * Texture Compression: yes
14:01:29:    - DXT: yes
14:01:29:    - VTC: no
14:01:29:    - PVRTC: no
14:01:29:    - ATC: no
14:01:29:    - ETC1: no
14:01:29:    - ETC2: no
14:01:29:    - BC4/BC5: yes
14:01:29:    - BC6H/BC7: yes
14:01:29:    - ASTC: no
14:01:29:  * Hardware Occlusion Query: yes
14:01:29:  * User clip planes: yes
14:01:29:  * VET_UBYTE4 vertex element type: yes
14:01:29:  * Infinite far plane projection: yes
14:01:29:  * Hardware render-to-texture: yes
14:01:29:  * Floating point textures: yes
14:01:29:  * Non-power-of-two textures: yes
14:01:29:  * 1d textures: yes
14:01:29:  * Volume textures: yes
14:01:29:  * Max Texture resolution (2D) 16384
14:01:29:  * Max Texture resolution (3D) 2048
14:01:29:  * Max Texture resolution (Cubemaps) 16384
14:01:29:  * Multiple Render Targets: 8
14:01:29:    - With different bit depths: yes
14:01:29:  * Point Sprites: yes
14:01:29:  * Extended point parameters: yes
14:01:29:  * Max Point Size: 256
14:01:29:  * Vertex texture fetch: yes
14:01:29:  * Number of world matrices: 0
14:01:29:  * Number of texture units: 16
14:01:29:  * Stencil buffer depth: 8
14:01:29:  * Number of vertex blend matrices: 0
14:01:29:    - Max vertex textures: 4
14:01:29:    - Vertex textures shared: no
14:01:29:  * Render to Vertex Buffer : yes
14:01:29:  * Hardware Atomic Counters: no
14:01:29:  * Shader 16-bit floating point (half): no
14:01:29:  * Compute max threads per threadgroup per axis: 1024, 1024, 64
14:01:29:  * Compute max threads per threadgroup total: 1024
14:01:29:  * Using Reverse Z: yes
14:01:29: DefaultWorkQueue('Root') initialising on thread main.
14:01:29: Particle Renderer Type 'billboard' registered
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/Common' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/Common/Any' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/Common/HLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/Common/GLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/Common/Metal' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/JW' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/JW/Metal' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/JW/GLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/materials/JW/HLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/Hlms/Common/Any' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/Hlms/Common/HLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/Hlms/Common/GLSL' of type 'FileSystem' to resource group 'General'
14:01:29: Added resource location 'D:\FFx32\ogre resources/Hlms/Common/Metal' of type 'FileSystem' to resource group 'General'
14:01:29: Creating resource group Popular
14:01:29: Added resource location 'D:\FFx32\ogre resources/2.0/scripts/Compositors' of type 'FileSystem' to resource group 'Popular'
14:01:29: Parsing scripts for resource group Autodetect
14:01:29: Finished parsing scripts for resource group Autodetect
14:01:29: Creating resources for group Autodetect
14:01:29: All done
14:01:29: Parsing scripts for resource group General
14:01:29: Parsing script Quad.program
14:01:29: Parsing script Atmosphere.material
14:01:29: Parsing script Copyback.material
14:01:29: Parsing script DepthUtils.material
14:01:29: Parsing script DPM.material
14:01:29: Parsing script DPSM.material
14:01:29: Parsing script EsmGaussianBlurLogFilter.material
14:01:29: Parsing script HiddenAreaMeshVr.material
14:01:29: Parsing script PccDepthCompressor.material
14:01:29: Parsing script RadialDensityMask.material
14:01:29: Parsing script Sky.material
14:01:29: Parsing script JWCopy.material
14:01:29: Parsing script JWDepthOfField.material
14:01:29: Parsing script JWFalseColorStereo.material
14:01:29: Parsing script JWFog.material
14:01:29: Parsing script JWGreenScreen.material
14:01:29: Parsing script JWMirrorDepth.material
14:01:29: Parsing script JWMirrorDepthMSAA.material
14:01:29: Parsing script JWResolveMSAADepth.material
14:01:29: Parsing script JWStereo.material
14:01:30: Parsing script SelectionHalo.material
14:01:30: Parsing script EsmGaussianBlurLogFilter.material.json
14:01:30: Parsing script Mipmaps.material.json
14:01:30: Finished parsing scripts for resource group General
14:01:30: Creating resources for group General
14:01:30: All done
14:01:30: Parsing scripts for resource group Internal
14:01:30: Finished parsing scripts for resource group Internal
14:01:30: Creating resources for group Internal
14:01:30: All done
14:01:30: Parsing scripts for resource group Popular
14:01:30: Parsing script JWDepthOnlyRender.compositor
14:01:30: Parsing script JWMirrorRender.compositor
14:01:30: Parsing script JWNodes2.compositor
14:01:30: Finished parsing scripts for resource group Popular
14:01:30: Creating resources for group Popular
14:01:30: All done
14:01:30: D3D11RenderSystem::_createRenderWindow "foo", 40x40 windowed  miscParams: FSAA=1x externalWindowHandle=198772 gamma=true reverse_depth=true vsync=true 
14:01:34: D3D11RenderSystem::_createRenderWindow "foo", 202x109 windowed  miscParams: FSAA=1x externalWindowHandle=198504 gamma=true reverse_depth=true vsync=true 
14:01:34: D3D11RenderSystem::_createRenderWindow "foo", 202x109 windowed  miscParams: FSAA=4x externalWindowHandle=198504 gamma=true reverse_depth=true vsync=true 
14:01:35: D3D11RenderSystem::_createRenderWindow "foo", 467x467 windowed  miscParams: FSAA=1x externalWindowHandle=133384 gamma=true reverse_depth=true vsync=true 
14:01:35: D3D11RenderSystem::_createRenderWindow "foo", 467x467 windowed  miscParams: FSAA=4x externalWindowHandle=133384 gamma=true reverse_depth=true vsync=true 
14:01:35: D3D11RenderSystem::_createRenderWindow "foo", 134x134 windowed  miscParams: FSAA=1x externalWindowHandle=525710 gamma=true reverse_depth=true vsync=true 
14:01:35: D3D11RenderSystem::_createRenderWindow "foo", 134x134 windowed  miscParams: FSAA=4x externalWindowHandle=525710 gamma=true reverse_depth=true vsync=true 
14:01:49: OGRE EXCEPTION(3:RenderingAPIException): D3D11 device cannot draw
Error Description:ID3D11DeviceContext::Draw: The Pixel Shader expects a Render Target View bound to slot 0, but none is bound. This is OK, as writes of an unbound Render Target View are discarded. It is also possible the developer knows the data will not be used anyway. This is only a problem if the developer actually intended to bind a Render Target View here.

Active OGRE shaders:
VS = Ogre/Compositor/Quad_vs_HLSL
FS = JW/DepthResolve_ps_hlsl in D3D11RenderSystem::_render at D:\MoreCode\Ogre\ogre-next-fork\RenderSystems\Direct3D11\src\OgreD3D11RenderSystem.cpp (line 3177)

The compositor node in which the problem happens:

Code: Select all

compositor_node JWDepthResolve
{
    in 0 colorTx
    in 1 msaaDepth
    
    texture resolvedDepth target_width target_height PFG_D32_FLOAT

	target resolvedDepth
	{
		pass render_quad
		{
			load { all dont_care }
			material JWResolveMSAADepth
			input 0 msaaDepth
			identifier 926
		}
	}
	
	out 0 colorTx
	out 1 resolvedDepth
}

Here is the material script:

Code: Select all

material JWResolveMSAADepth
{
	technique
	{
		pass
		{
			depth_check on
			depth_func always_pass
			depth_write on
			cull_hardware none
			colour_write off

			vertex_program_ref Ogre/Compositor/Quad_vs
			{
			}
			
			fragment_program_ref JW/DepthResolve_ps
			{
			}

			texture_unit depth
			{
				tex_address_mode	clamp
				filtering none
			}
		}
	}
}

The HLSL implementation of the fragment shader is identical to the shader Resolve_1xFP32_Subsample0_ps.hlsl used in a couple of the Ogre sample programs:

Code: Select all

Texture2DMS<float>	myTexture : register(t0);

struct PS_INPUT
{
	float2 uv0			: TEXCOORD0;
};

float main
(
	PS_INPUT inPs,
	float4 gl_FragCoord : SV_Position
) : SV_Target
{
	return myTexture.Load( int2( gl_FragCoord.xy ), 0 ).x;
}

When the error message says that nothing is bound to slot 0, it sound like the shader is not receiving the MSAA depth texture that is supposed to be the input for this quad pass. But in a CompositorWorkspaceListener passPreExecute method, when I see the pass in question I do this

Code: Select all

const Ogre::CompositorNode* node = compPass->getParentNode();
Ogre::TextureGpu* depthInTex = node->getDefinedTexture("msaaDepth");

and I can see in the debugger that depthInTex is a texture with the expected depth pixel format and number of samples. Can anyone help me understand the error?

jwwalker
Goblin
Posts: 285
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 21

Re: Another MSAA error, this time with Direct3D

Post by jwwalker »

Another thing I tried in passPreExecute: I got a pointer to the Material being used by the CompositorPassQuad, got the Technique from the Material, got the Pass from the Technique, got the TextureUnitState from the Pass, and got the TextureGpu from the TextureUnitState. That texture also looks like just what I expected.

User avatar
dark_sylinc
OGRE Team Member
OGRE Team Member
Posts: 5502
Joined: Sat Jul 21, 2007 4:55 pm
Location: Buenos Aires, Argentina
x 1370

Re: Another MSAA error, this time with Direct3D

Post by dark_sylinc »

Your pixel shader must return SV_Depth instead of SV_Target when outputting to depth.
Direct3D is complaining that you expect to write to a colour target but none is bound (because there isn't, a depth buffer is bound and you write to it via SV_Depth).

Cheers

jwwalker
Goblin
Posts: 285
Joined: Thu Aug 12, 2021 10:06 pm
Location: San Diego, CA, USA
x 21

Re: Another MSAA error, this time with Direct3D

Post by jwwalker »

Thanks!