Closed lemoon closed 1 year ago
I see you selected some examples twice and some examples seem to work fine judging just by the logs. Can you please separate them and show the ones that fail again.
As for this error:
error (invalid argument): in 'CreateResourceHeap': cannot create resource heap with empty list of heap bindings
cannot create resource heap without bindings in pipeline layout
This is a small mistake, I haven't updated the Compute Shader example in a while, but you can simply change this line:
LLGL::Parse("cbuffer(2):comp, rwbuffer(3):comp, rwbuffer(4):comp")
... to this:
LLGL::Parse("heap{cbuffer(2):comp, rwbuffer(3):comp, rwbuffer(4):comp}")
and it should fix it. For a ResourceHeap
, the resource bindings need to be specified as heapBindings
and the Parse
function reads the above layout as regular bindings
.
The GLSL errors ERROR: 0:2: '' : version '130' is not supported
can probably be fixed by just raising the GLSL shader version to 410
(in the respective .vert
and .frag
files) which is the highest version available on macOS.
UPDATE: I fixed two of these issues with c24c33e and dd5bb47.
I see you selected some examples twice and some examples seem to work fine judging just by the logs. Can you please separate them and show the ones that fail again.
As for this error:
error (invalid argument): in 'CreateResourceHeap': cannot create resource heap with empty list of heap bindings cannot create resource heap without bindings in pipeline layout
This is a small mistake, I haven't updated the Compute Shader example in a while, but you can simply change this line:
LLGL::Parse("cbuffer(2):comp, rwbuffer(3):comp, rwbuffer(4):comp")
... to this:
LLGL::Parse("heap{cbuffer(2):comp, rwbuffer(3):comp, rwbuffer(4):comp}")
and it should fix it. For a
ResourceHeap
, the resource bindings need to be specified asheapBindings
and theParse
function reads the above layout as regularbindings
.The GLSL errors
ERROR: 0:2: '' : version '130' is not supported
can probably be fixed by just raising the GLSL shader version to410
(in the respective.vert
and.frag
files) which is the highest version available on macOS.UPDATE: I fixed two of these issues with c24c33e and dd5bb47.
Commit: dd5bb47d6eee6fb3f30885a77e7cc40630ab13aa [dd5bb47d] Parents: c24c33efb5 Author: Laura Hermanns lukas.hermanns90@gmail.com Labels: HEAD master origin/master origin/HEAD
This is the code I pulled from the latest master commit, and here is the error log from the execution.
select example: 1
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
Renderer: Metal 2.1
Device: Apple M2 Max
Vendor: Apple
Shading Language: Metal Shading Language
Swap Chain Format: BGRA8UNorm
Depth/Stencil Format: <undefined>
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 2
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
error (invalid argument): in 'CreatePipelineState': cannot create graphics PSO without vertex shader
error (invalid argument): in 'CreatePipelineState': cannot create graphics PSO with compute shader being assigned to tessellation control stage
error (invalid argument): in 'CreatePipelineState': cannot create graphics PSO with vertex shader being assigned to tessellation evaluation stage
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 3
select renderer:
1.) Null
2.) OpenGL
3.) Metal
2
selected renderer: OpenGL
render system:
renderer: OpenGL 4.1 Metal - 83.1
device: Apple M2 Max
vendor: Apple
shading language: GLSL 4.10
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: RGBA8UNorm
depthStencilFormat: D24UNormS8UInt
error (unsupported feature): in 'CreateTexture': cannot create texture with unsupported format: BC1UNorm
texture creation time: 1.09454 ms
press TAB KEY to switch between five different texture samplers
UNSUPPORTED (log once): POSSIBLE ISSUE: unit 0 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
select example: 3
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 4
select renderer:
1.) Null
2.) OpenGL
3.) Metal
2
selected renderer: OpenGL
render system:
renderer: OpenGL 4.1 Metal - 83.1
device: Apple M2 Max
vendor: Apple
shading language: GLSL 4.10
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: RGBA8UNorm
depthStencilFormat: D24UNormS8UInt
loaded texture: ../../Media/Textures/Crate.jpg
error (invalid argument): in 'CreateRenderTarget': cannot use color format for depth-stencil attachment
in 'ToGLDepthStencilAttachmentBinding': reached code path that should be unreachable
./RunExamplesMacOS.command: line 38: 6906 Abort trap: 6 ../../../$BUILD_DIR/Example_RenderTarget.app/Contents/MacOS/Example_RenderTarget
select example:
select example: 4
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
loaded texture: ../../Media/Textures/Crate.jpg
-[MTLTextureDescriptorInternal validateWithDevice:]:1344: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor sampleCount (8) is not supported by device.
'
./RunExamplesMacOS.command: line 38: 6910 Abort trap: 6 ../../../$BUILD_DIR/Example_RenderTarget.app/Contents/MacOS/Example_RenderTarget
select example:
select example: 5
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 6
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
loaded texture: ../../Media/Textures/Plants_0.png
loaded texture: ../../Media/Textures/Plants_1.png
loaded texture: ../../Media/Textures/Plants_2.png
loaded texture: ../../Media/Textures/Plants_3.png
loaded texture: ../../Media/Textures/Plants_4.png
loaded texture: ../../Media/Textures/Plants_5.png
loaded texture: ../../Media/Textures/Plants_6.png
loaded texture: ../../Media/Textures/Plants_7.png
loaded texture: ../../Media/Textures/Plants_8.png
loaded texture: ../../Media/Textures/Plants_9.png
loaded texture: ../../Media/Textures/Grass.jpg
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 7
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
shaders not available for selected renderer in this example
select example:
select example: 8
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
-[MTLTextureDescriptorInternal validateWithDevice:]:1344: failed assertion `Texture Descriptor Validation
MTLTextureDescriptor sampleCount (8) is not supported by device.
'
./RunExamplesMacOS.command: line 38: 6937 Abort trap: 6 ../../../$BUILD_DIR/Example_PostProcessing.app/Contents/MacOS/Example_PostProcessing
select example:
select example: 9
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example: 10
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example: 12
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 800
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example: 16
select renderer:
1.) Null
2.) OpenGL
3.) Metal
3
selected renderer: Metal
render system:
renderer: Metal 2.1
device: Apple M2 Max
vendor: Apple
shading language: Metal Shading Language
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: BGRA8UNorm
depthStencilFormat: D32FloatS8X24UInt
loaded texture: ../../Media/Textures/Crate.jpg
loaded texture: ../../Media/Textures/TilesGray512.jpg
loaded texture: ../../Media/Textures/TilesBlue512.jpg
failed to create instance of <MTLRenderPipelineState>: rasterSampleCount (8) is not supported by device.
select example:
select example: 12
select renderer:
1.) Null
2.) OpenGL
3.) Metal
2
selected renderer: OpenGL
render system:
renderer: OpenGL 4.1 Metal - 83.1
device: Apple M2 Max
vendor: Apple
shading language: GLSL 4.10
swap-chain:
resolution: 800 x 800
samples: 8
colorFormat: RGBA8UNorm
depthStencilFormat: D24UNormS8UInt
compute shaders are not supported by this renderer
select example:
select example: 16
2select renderer:
1.) Null
2.) OpenGL
3.) Metal
selected renderer: OpenGL
render system:
renderer: OpenGL 4.1 Metal - 83.1
device: Apple M2 Max
vendor: Apple
shading language: GLSL 4.10
swap-chain:
resolution: 800 x 600
samples: 8
colorFormat: RGBA8UNorm
depthStencilFormat: D24UNormS8UInt
loaded texture: ../../Media/Textures/Crate.jpg
loaded texture: ../../Media/Textures/TilesGray512.jpg
loaded texture: ../../Media/Textures/TilesBlue512.jpg
ERROR: 0:3: '' : version '430' is not supported
ERROR: 0:3: '' : syntax error: #version
ERROR: 0:4: '' : #version required and missing.
ERROR: 0:12: '0' : syntax error: integers in layouts require GLSL 140 or later
ERROR: 0:3: '' : version '430' is not supported
ERROR: 0:3: '' : syntax error: #version
ERROR: 0:4: '' : #version required and missing.
ERROR: 0:7: '0' : syntax error: integers in layouts require GLSL 140 or later
Most of the issues seem to be coming from lower multi-sampling support. I addressed that in b46428e.
As for example 16 (Resource Binding): This one requires GLSL 430 for the GL backend, which is not supported on macOS, so you'll have to stick with Metal for that example and the OpenGL support is fragile on macOS anyway as it has been deprecated a long time ago.
I can't tell why this error shows up, though:
in 'CreateRenderTarget': cannot use color format for depth-stencil attachment
The RenderTarget example should only create a custom depth texture with the D32Float
format, which is not a color format, so I don't understand how this ends up with a wrong configuration.
In case you are able to compile and run this example through Xcode, can you set a breakpoint at the LLGL_UNREACHABLE();
line in GLRenderTarget.cpp and tell me what value lldb shows you for the format
parameter?
Besides that, I would stick to Metal over OpenGL on the modern M1 and M2 Macs.
Hello-Triangle still not work
After generating the Xcode project, when debugging, the paths for resources (such as "Example.metal") need to be redefined. Could you provide a command for this? My command is as follows:
#!/bin/sh
SOURCE_DIR="$(dirname $0)"
BUILD_DIR="$SOURCE_DIR/xcode_macos"
# Ensure we are inside the repository folder
if [ ! -f "$SOURCE_DIR/CMakeLists.txt" ]; then
echo "error: file not found: CMakeLists.txt"
exit 1
fi
# Make output build folder
if [ "$#" -eq 1 ]; then
BUILD_DIR=$1
else
if [ ! "$#" -eq 0 ]; then
echo "error: too many arguemnts"
echo "usage: BuildMacOS.command [BUILD_DIR]"
exit 1
fi
fi
if [ ! -d "$BUILD_DIR" ]; then
mkdir "$BUILD_DIR"
fi
# Checkout external depenencies
GAUSSIAN_LIB_DIR="$BUILD_DIR/GaussianLib/include"
if [ ! -d "$GAUSSIAN_LIB_DIR" ]; then
(cd "$BUILD_DIR" && git clone https://github.com/LukasBanana/GaussianLib.git)
fi
# Build into output directory
cmake -G "Xcode" \
-DLLGL_BUILD_RENDERER_OPENGL=ON \
-DLLGL_BUILD_RENDERER_METAL=ON \
-DLLGL_BUILD_EXAMPLES=ON \
-DGaussLib_INCLUDE_DIR:STRING="$GAUSSIAN_LIB_DIR" \
-S "$SOURCE_DIR" \
-B "$BUILD_DIR"
I haven't found a way in CMake yet to define the working directories. That's why I added this note to the examples folder. And the RunExamplesMacOS.command
script automatically changes the working directory, but I don't know how to tell CMake to configure the projects this way.
The Hello Triangle tutorial doesn't use the ExampleBase project, so you'd have to change the sampling count to 4 yourself, that's what all Metal devices support. You can change it here: https://github.com/LukasBanana/LLGL/blob/95a613400fb7001306edbdb0c49cb32f8a284989/examples/Cpp/HelloTriangle/Example.cpp#L40
Thank you for your response. Placing all resources in a single directory instead of separate placements for each project, and then copying the resources during Xcode project generation, followed by concatenating the resource directory with their respective files, could be a potential solution. Due to this issue, many of my projects require manual modification of all paths for debugging. Unfortunately, I am unable to provide you with more debug information promptly at the moment. I will provide you with feedback as I continue to use it in subsequent processes. Once again, I appreciate your response.
by the way , "swapChainDesc.samples = 4 " is work for me.
I found some CMake options to generate the working directory automatically:
I'll take a closer look tomorrow as this will require a higher CMake version as what I used before.
I added the automatic generation of the working directories for VS and Xcode with 9561114.
Any updates on this issue @lemoon? I cannot test on an M2 device myself.
Several issues in the Mac backend have been fixed in recent commits. Please feel free to open a new ticket if any of the mentioned issued persist.
Hi,
I found many examples can not excuted in apple M2,Is there some errors for m2 ?
excute commands
./BuildMacOS.command ./RunExamplesMacOS.command