OGRECave / ogre-next

aka ogre v2 - scene-oriented, flexible 3D C++ engine
https://ogrecave.github.io/ogre-next/api/latest
Other
1.08k stars 233 forks source link

Sample_InstancedStereo shader compile error on Metal #464

Closed jwwalker closed 1 month ago

jwwalker commented 1 month ago

System Information

Detailed description

Sample_InstancedStereo does not run on macOS/Metal.

Ogre.log

10:30:32: Creating resource group General
10:30:32: Creating resource group Internal
10:30:32: Creating resource group Autodetect
10:30:32: SceneManagerFactory for type 'DefaultSceneManager' registered.
10:30:32: Registering ResourceManager for type Material
10:30:32: Registering ResourceManager for type Mesh
10:30:32: Registering ResourceManager for type Mesh2
10:30:32: Registering ResourceManager for type OldSkeleton
10:30:32: MovableObjectFactory for type 'ParticleSystem' registered.
10:30:32: ArchiveFactory for archive type FileSystem registered.
10:30:32: ArchiveFactory for archive type Zip registered.
10:30:32: ArchiveFactory for archive type EmbeddedZip registered.
10:30:32: DDS codec registering
10:30:32: FreeImage version: 3.18.0
10:30:32: This program uses FreeImage, a free, open source image library supporting all common bitmap formats. See http://freeimage.sourceforge.net for details
10:30:32: 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
10:30:32: OITD codec registering
10:30:32: Registering ResourceManager for type HighLevelGpuProgram
10:30:32: WARNING: NS Bundle Identifier not set!
10:30:32: WARNING: NS Bundle Identifier not set!
10:30:32: MovableObjectFactory for type 'Decal' registered.
10:30:32: MovableObjectFactory for type 'InternalCubemapProbe' registered.
10:30:32: MovableObjectFactory for type 'Entity' registered.
10:30:32: MovableObjectFactory for type 'Item' registered.
10:30:32: MovableObjectFactory for type 'Light' registered.
10:30:32: MovableObjectFactory for type 'ParticleSystem2' registered.
10:30:32: MovableObjectFactory for type 'Rectangle2Dv2' registered.
10:30:32: MovableObjectFactory for type 'BillboardSet' registered.
10:30:32: MovableObjectFactory for type 'ManualObject2' registered.
10:30:32: MovableObjectFactory for type 'BillboardChain' registered.
10:30:32: MovableObjectFactory for type 'RibbonTrail' registered.
10:30:32: MovableObjectFactory for type 'WireAabb' registered.
10:30:32: Loading library RenderSystem_Metal
10:30:32: Installing plugin: Metal RenderSystem
10:30:32: Metal: Devices Detection Starts
10:30:32: Metal: "Intel(R) UHD Graphics 630"
10:30:32: Metal: "AMD Radeon Pro 560X"
10:30:32: Metal: Devices Detection Ends
10:30:32: Plugin successfully installed
10:30:32: Loading library Plugin_ParticleFX
10:30:32: Installing plugin: ParticleFX
10:30:32: Particle Emitter Type 'Point' registered
10:30:32: Particle Emitter Type 'Box' registered
10:30:32: Particle Emitter Type 'Ellipsoid' registered
10:30:32: Particle Emitter Type 'Cylinder' registered
10:30:32: Particle Emitter Type 'Ring' registered
10:30:32: Particle Emitter Type 'HollowEllipsoid' registered
10:30:32: Particle Affector Type 'LinearForce' registered
10:30:32: Particle Affector Type 'ColourFader' registered
10:30:32: Particle Affector Type 'ColourFader2' registered
10:30:32: Particle Affector Type 'ColourImage' registered
10:30:32: Particle Affector Type 'ColourInterpolator' registered
10:30:32: Particle Affector Type 'ScaleInterpolator' registered
10:30:32: Particle Affector Type 'Scaler' registered
10:30:32: Particle Affector Type 'Rotator' registered
10:30:32: Particle Affector Type 'DirectionRandomiser' registered
10:30:32: Particle Affector Type 'DeflectorPlane' registered
10:30:32: Plugin successfully installed
10:30:32: Loading library Plugin_ParticleFX2
10:30:32: Installing plugin: ParticleFX2
10:30:32: Plugin successfully installed
10:30:32: *-*-* OGRE Initialising
10:30:32: *-*-* Version 4.0.0unstable (F)
10:30:37: CPU Identifier & Features
10:30:37: -------------------------
10:30:37:  *   CPU ID: GenuineIntel: Intel(R) Core(TM) i7-8850H CPU @ 2.60GHz
10:30:37:  *   Logical cores: 12
10:30:37:  *      SSE: yes
10:30:37:  *     SSE2: yes
10:30:37:  *     SSE3: yes
10:30:37:  *      MMX: yes
10:30:37:  *   MMXEXT: yes
10:30:37:  *    3DNOW: no
10:30:37:  * 3DNOWEXT: no
10:30:37:  *     CMOV: yes
10:30:37:  *      TSC: yes
10:30:37:  *      FPU: yes
10:30:37:  *      PRO: yes
10:30:37:  *       HT: no
10:30:37: -------------------------
10:30:37: Metal: Devices Detection Starts
10:30:37: Metal: "Intel(R) UHD Graphics 630"
10:30:37: Metal: "AMD Radeon Pro 560X"
10:30:37: Metal: Devices Detection Ends
10:30:37: Metal: Requested "(default)", selected "AMD Radeon Pro 560X (system default)"
10:30:37: Supports: OSX_GPUFamily1_v1
10:30:37: Registering ResourceManager for type GpuProgram
10:30:37: DefaultWorkQueue('Root') initialising on thread main.
10:30:37: Particle Renderer Type 'billboard' registered
10:30:37: OverlayElementFactory for type Panel registered.
10:30:37: OverlayElementFactory for type BorderPanel registered.
10:30:37: OverlayElementFactory for type TextArea registered.
10:30:37: Registering ResourceManager for type Font
10:30:37: Creating resource group Essential
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/DebugPack.zip' of type 'Zip' to resource group 'Essential'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/CornellBox.zip' of type 'Zip' to resource group 'Essential'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/materials/Common' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/materials/Common/Any' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/materials/Common/GLSL' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/materials/Common/HLSL' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/materials/Common/Metal' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Hlms/Common/Any' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Hlms/Common/GLSL' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Hlms/Common/HLSL' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Hlms/Common/Metal' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Compute/Algorithms/IBL' of type 'FileSystem' to resource group 'General'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/Compute/Tools/Any' of type 'FileSystem' to resource group 'General'
10:30:37: Creating resource group Popular
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/2.0/scripts/Compositors' of type 'FileSystem' to resource group 'Popular'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/models' of type 'FileSystem' to resource group 'Popular'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/textures' of type 'FileSystem' to resource group 'Popular'
10:30:37: Added resource location '/Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources/textures/Cubemaps' of type 'FileSystem' to resource group 'Popular'
10:30:37: WARNING: NS Bundle Identifier not set!
10:30:37: WARNING: NS Bundle Identifier not set!
10:30:37: [INFO] Texture cache not found at /Volumes/Work/non-repo-libraries/Ogre-fork-build6/bin/Debug/Sample_InstancedStereo.app/Contents/Resources//textureMetadataCache.json
10:30:37: Parsing scripts for resource group Autodetect
10:30:37: Finished parsing scripts for resource group Autodetect
10:30:37: Creating resources for group Autodetect
10:30:37: All done
10:30:37: Parsing scripts for resource group Essential
10:30:37: Parsing script Materials.material
10:30:37: Parsing script CornellBox.material.json
10:30:37: Parsing script DebugFont.fontdef
10:30:37: Finished parsing scripts for resource group Essential
10:30:37: Creating resources for group Essential
10:30:37: All done
10:30:37: Parsing scripts for resource group General
10:30:37: Parsing script Quad.program
10:30:37: Shader Ogre/Compositor/Quad_vs_Metal compiled successfully.
10:30:37: Shader Ogre/Compositor/QuadCameraDir_vs_Metal compiled successfully.
10:30:37: Shader Ogre/Compositor/QuadCameraDirNoUV_vs_Metal compiled successfully.
10:30:37: Parsing script HiddenAreaMeshVr.material
10:30:37: Shader Ogre/VR/HiddenAreaMeshVr_vs_Metal compiled successfully.
10:30:37: Shader Ogre/VR/HiddenAreaMeshVr_ps_Metal compiled successfully.
10:30:37: Parsing script EsmGaussianBlurLogFilter.material
10:30:37: Shader ESM/GaussianLogFilterH_ps_Metal compiled successfully.
10:30:37: Shader ESM/GaussianLogFilterV_ps_Metal compiled successfully.
10:30:37: Parsing script RadialDensityMask.material
10:30:37: Shader Ogre/Compositor/RadialDensityMask_vs_Metal compiled successfully.
10:30:37: Shader Ogre/VR/RadialDensityMask_ps_Metal compiled successfully.
10:30:37: Parsing script DPSM.material
10:30:37: Shader Ogre/DPSM/CubeToDpsm_ps_Metal compiled successfully.
10:30:37: Shader Ogre/DPSM/CubeToDpsm_Colour_ps_Metal compiled successfully.
10:30:37: Parsing script Atmosphere.material
10:30:37: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource metal_stdlib in resource group General or any other group. in ResourceGroupManager::openResource at /Volumes/Work/git-repos/ogre-next-fork/OgreMain/src/OgreResourceGroupManager.cpp (line 737)
10:30:37: Shader Ogre/Atmo/NprSky_ps_Metal compiled successfully.
10:30:37: Parsing script DPM.material
10:30:37: Shader Ogre/DPM/CubeToDpm_4xFP16_ps_Metal compiled successfully.
10:30:37: Parsing script PccDepthCompressor.material
10:30:37: OGRE EXCEPTION(6:FileNotFoundException): Cannot locate resource metal_stdlib in resource group General or any other group. in ResourceGroupManager::openResource at /Volumes/Work/git-repos/ogre-next-fork/OgreMain/src/OgreResourceGroupManager.cpp (line 737)
10:30:37: Shader PccDepthCompressor_ps_Metal compiled successfully.
10:30:37: Parsing script DepthUtils.material
10:30:37: Shader Ogre/Depth/DownscaleMax_ps_Metal compiled successfully.
10:30:37: Parsing script Sky.material
10:30:37: Shader Ogre/Sky/Cubemap_ps_Metal compiled successfully.
10:30:37: Shader Ogre/Sky/Equirectangular_ps_Metal compiled successfully.
10:30:37: Parsing script Copyback.material
10:30:37: Shader Ogre/Copy/4xFP32_ps_Metal compiled successfully.
10:30:37: Shader Ogre/Copy/4xFP32_2DArray_ps_Metal compiled successfully.
10:30:37: Shader Ogre/Copy/1xFP32_ps_Metal compiled successfully.
10:30:37: Shader Ogre/Resolve/1xFP32_Subsample0_ps_Metal compiled successfully.
10:30:37: Parsing script EsmGaussianBlurLogFilter.material.json
10:30:37: Parsing script Mipmaps.material.json
10:30:37: Parsing script IBL.material.json
10:30:37: Finished parsing scripts for resource group General
10:30:37: Creating resources for group General
10:30:37: All done
10:30:37: Parsing scripts for resource group Internal
10:30:37: Finished parsing scripts for resource group Internal
10:30:37: Creating resources for group Internal
10:30:37: All done
10:30:37: Parsing scripts for resource group Popular
10:30:37: Parsing script LocalCubemaps.compositor
10:30:37: Parsing script StencilTest.compositor
10:30:37: Parsing script TutorialUav02_Setup.compositor
10:30:37: Parsing script StereoRendering.compositor
10:30:37: Parsing script ScreenSpaceReflections.compositor
10:30:37: Parsing script StaticShadowMaps.compositor
10:30:37: Parsing script UvBaking.compositor
10:30:37: Parsing script ShadowMapDebugging.compositor
10:30:37: Parsing script Refractions.compositor
10:30:37: Parsing script Tutorial_DynamicCubemap.compositor
10:30:37: Parsing script IrradianceFieldRaster.compositor
10:30:37: Parsing script PbsMaterials.compositor
10:30:37: Parsing script Tutorial_Terrain.compositor
10:30:37: Parsing script InstancedStereo.compositor
10:30:37: Parsing script Tutorial_OpenVRWorkspace.compositor
10:30:37: Parsing script TutorialUav01_Setup.compositor
10:30:37: Parsing script TutorialSky_Postprocess.compositor
10:30:37: Parsing script Tutorial_ReconstructPosFromDepth.compositor
10:30:37: Parsing script PlanarReflections.compositor
10:30:37: Finished parsing scripts for resource group Popular
10:30:37: Creating resources for group Popular
10:30:37: All done
10:30:37: Mesh: Loading Cube_d.mesh.
10:30:37: WARNING: Cube_d.mesh is an older format ([MeshSerializer_v2.1 R1]); you should upgrade it as soon as possible using the OgreMeshTool tool.
10:30:37: Shader 100000000VertexShader_vs compiled successfully.
10:30:37: Shader 100000001VertexShader_vs compiled successfully.
10:30:38: Metal SL Compiler Error in 100000002VertexShader_vs:
program_source:710:3: error: no member named 'gl_ViewportIndex' in 'PS_INPUT'
                outVs_viewportIndex     = int( inVs_stereoDrawId & 0x01u );
  ^~~~~~~~~~~~~~~~~~~
program_source:120:35: note: expanded from macro 'outVs_viewportIndex'
#define outVs_viewportIndex outVs.gl_ViewportIndex
                            ~~~~~ ^

10:30:38: Error retrieving entry point 'main_metal' in shader 100000002VertexShader_vs
10:30:38: OGRE EXCEPTION(3:RenderingAPIException): Vertex Program 100000002VertexShader_vs failed to compile. See compile log above for details. in MetalProgram::compile at /Volumes/Work/git-repos/ogre-next-fork/RenderSystems/Metal/src/OgreMetalProgram.mm (line 266)
10:30:38: High-level program 100000002VertexShader_vs encountered an error during loading and is thus not supported.
OGRE EXCEPTION(3:RenderingAPIException): Vertex Program 100000002VertexShader_vs failed to compile. See compile log above for details. in MetalProgram::compile at /Volumes/Work/git-repos/ogre-next-fork/RenderSystems/Metal/src/OgreMetalProgram.mm (line 266)
10:30:38: Metal SL Compiler Error in 100000002VertexShader_vs:
program_source:710:3: error: no member named 'gl_ViewportIndex' in 'PS_INPUT'
                outVs_viewportIndex     = int( inVs_stereoDrawId & 0x01u );
  ^~~~~~~~~~~~~~~~~~~
program_source:120:35: note: expanded from macro 'outVs_viewportIndex'
#define outVs_viewportIndex outVs.gl_ViewportIndex
                            ~~~~~ ^

10:30:38: Error retrieving entry point 'main_metal' in shader 100000002VertexShader_vs
10:30:38: OGRE EXCEPTION(3:RenderingAPIException): Vertex Program 100000002VertexShader_vs failed to compile. See compile log above for details. in MetalProgram::compile at /Volumes/Work/git-repos/ogre-next-fork/RenderSystems/Metal/src/OgreMetalProgram.mm (line 266)
10:30:38: WARNING: GraphicsSystem::deinitialize() not called!!!
darksylinc commented 1 month ago

Does it get fixed if you change Samples/Media/Hlms/Pbs/Metal/VertexShader_vs.metal like this...?

struct PS_INPUT
{
@insertpiece( VStoPS_block )
    float4 gl_Position [[position]];

    @property( hlms_instanced_stereo )
        uint gl_ViewportIndex [[viewport_array_index]];
    @end
    @property( hlms_pso_clip_distances )
        float gl_ClipDistance [[clip_distance]] [@value( hlms_pso_clip_distances )];
    @end
};

The necessary functionality was added to Metal 2.0 (macOS) & 2.1 (iOS).

Note that I added the declaration of gl_ViewportIndex.

jwwalker commented 1 month ago

@darksylinc Yes, that change does fix it.

darksylinc commented 1 month ago

Thanks! Pushed it!