LukasBanana / LLGL

Low Level Graphics Library (LLGL) is a thin abstraction layer for the modern graphics APIs OpenGL, Direct3D, Vulkan, and Metal
BSD 3-Clause "New" or "Revised" License
2.05k stars 139 forks source link

Error Logs in apple M2 device #89

Closed lemoon closed 1 year ago

lemoon commented 1 year ago

Hi,

I found many examples can not excuted in apple M2,Is there some errors for m2 ?

❯ ./RunExamplesMacOS.command
1) Hello Triangle       7) Stream Output      13) Animation
2) Tessellation         8) Post Processing    14) Cloth Physics
3) Texturing            9) Shadow Mapping     15) Primitive Restart
4) Render Target       10) Stencil Buffer     16) Resource Binding
5) Buffer Array        11) Volume Rendering
6) Instancing          12) Compute Shader
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

error (invalid argument): in 'CreateResourceHeap': cannot create resource heap with empty list of heap bindings
cannot create resource heap without bindings in pipeline layout
select example: 1
select renderer:
 1.) Null
 2.) OpenGL
 3.) Metal
2
selected renderer: OpenGL
Renderer:             OpenGL 4.1 Metal - 83.1
Device:               Apple M2 Max
Vendor:               Apple
Shading Language:     GLSL 4.10
Swap Chain Format:    RGBA8UNorm
Depth/Stencil Format: <undefined>
select example: 2
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

press LEFT MOUSE BUTTON and move mouse on X axis to increase/decrease inner tessellation
press RIGHT MOUSE BUTTON and move mouse on X axis to increase/decrease outer tessellation
press MIDDLE MOUSE BUTTON and move mouse on X axis to increase/decrease twist
press TAB KEY to switch between wireframe modes
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: 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: 29.2515 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
texture attributes: addressModeU = MirrorOnce, addressModeV = Border           texture attributes: addressModeU = Mirror, addressModeV = Mirror               texture attributes: addressModeU = MirrorOnce, addressModeV = Border           texture attributes: addressModeU = Mirror, addressModeV = Mirror               texture attributes: addressModeU = MirrorOnce, addressModeV = Border           texture attributes: addressModeU = Mirror, addressModeV = Mirror               texture attributes: format = BC1UNorm

exit
q:
^Cselect 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: 68187 Abort trap: 6           ../../../$BUILD_DIR/Example_RenderTarget.app/Contents/MacOS/Example_RenderTarget
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: 68194 Abort trap: 6           ../../../$BUILD_DIR/Example_RenderTarget.app/Contents/MacOS/Example_RenderTarget
select example:
1) Hello Triangle       7) Stream Output      13) Animation
2) Tessellation         8) Post Processing    14) Cloth Physics
3) Texturing            9) Shadow Mapping     15) Primitive Restart
4) Render Target       10) Stencil Buffer     16) Resource Binding
5) Buffer Array        11) Volume Rendering
6) Instancing          12) Compute Shader
select example: 5
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: 0:2: '' :  version '130' is not supported
ERROR: 0:3: '' :  #version required and missing.

ERROR: 0:2: '' :  version '130' is not supported
ERROR: 0:3: '' :  #version required and missing.

^Cselect example: 6
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/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
press LEFT/RIGHT MOUSE BUTTON to rotate the camera around the scene
press R KEY to reload the shader program
press SPACE KEY to switch between pipeline states with and without alpha-to-coverage
Alpha-To-Coverage Disabled
Alpha-To-Coverage Enabled
Alpha-To-Coverage Disabled
Alpha-To-Coverage Enabled
Alpha-To-Coverage Disabled
Alpha-To-Coverage Enabled
Alpha-To-Coverage Disabled
Alpha-To-Coverage Enabled
Alpha-To-Coverage Disabled
Alpha-To-Coverage Enabled
select example: 9
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

select example: 10
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

select example: 11
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:            1
  colorFormat:        RGBA8UNorm
  depthStencilFormat: D24UNormS8UInt

press LEFT MOUSE BUTTON and move the mouse to ROTATE the model
press RIGHT MOUSE BUTTON and move the mouse on the X-axis to change the DENSITY THRESHOLD
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: 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

error (invalid argument): in 'CreateResourceHeap': cannot create resource heap with empty list of heap bindings
cannot create resource heap without bindings in pipeline layout
select example:

excute commands

./BuildMacOS.command ./RunExamplesMacOS.command

LukasBanana commented 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.

lemoon commented 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.

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
LukasBanana commented 1 year ago

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.

lemoon commented 1 year ago

Hello-Triangle still not work

image

image

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"
LukasBanana commented 1 year ago

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

lemoon commented 1 year ago

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.

LukasBanana commented 1 year ago

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.

LukasBanana commented 1 year ago

I added the automatic generation of the working directories for VS and Xcode with 9561114.

LukasBanana commented 1 year ago

Any updates on this issue @lemoon? I cannot test on an M2 device myself.

LukasBanana commented 1 year ago

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.