@@ -143,14 +143,46 @@ private void CreateResources()
143143 Shader [ ] shaders ;
144144 try
145145 {
146+ // Test if SPIRV compilation is available by attempting a simple operation
147+ Console . WriteLine ( "[DEBUG] Testing SPIRV library availability..." ) ;
148+
146149 shaders = factory . CreateFromSpirv ( vertex , fragment , options ) ;
147- Console . WriteLine ( $ "[DEBUG] Successfully created { shaders . Length } shaders") ;
150+ Console . WriteLine ( $ "[DEBUG] Successfully created { shaders . Length } shaders using SPIRV") ;
151+ }
152+ catch ( DllNotFoundException dllEx )
153+ {
154+ Console . WriteLine ( $ "[ERROR] SPIRV native library not found: { dllEx . Message } ") ;
155+ Console . WriteLine ( "[ERROR] This is likely due to missing libveldrid-spirv.so" ) ;
156+ Console . WriteLine ( "[ERROR] Falling back to alternative shader creation method..." ) ;
157+
158+ // For now, throw a more descriptive error
159+ throw new InvalidOperationException (
160+ "SPIRV shader compilation is not available. This is likely due to missing native dependencies (libveldrid-spirv.so). " +
161+ "Please ensure the Veldrid.SPIRV native library is properly installed." , dllEx ) ;
162+ }
163+ catch ( ArgumentNullException argEx )
164+ {
165+ Console . WriteLine ( $ "[ERROR] Null argument in shader creation: { argEx . Message } ") ;
166+ Console . WriteLine ( $ "[ERROR] This might be due to backend mismatch or SPIRV compilation failure") ;
167+
168+ // Check if the bytes are actually null
169+ Console . WriteLine ( $ "[DEBUG] Vertex shader bytes null: { vertexShaderSpirvBytes == null } ") ;
170+ Console . WriteLine ( $ "[DEBUG] Fragment shader bytes null: { fragmentShaderSpirvBytes == null } ") ;
171+
172+ throw new InvalidOperationException (
173+ $ "Shader creation failed with null bytes. Backend: { Surface . GraphicsDevice . BackendType } , " +
174+ $ "Vertex bytes: { vertexShaderSpirvBytes ? . Length ?? 0 } , Fragment bytes: { fragmentShaderSpirvBytes ? . Length ?? 0 } ", argEx ) ;
148175 }
149176 catch ( Exception ex )
150177 {
151178 Console . WriteLine ( $ "[ERROR] Failed to create shaders: { ex . GetType ( ) . Name } : { ex . Message } ") ;
152179 Console . WriteLine ( $ "[ERROR] Stack trace: { ex . StackTrace } ") ;
153- throw ;
180+
181+ // Provide more context in the error message
182+ throw new InvalidOperationException (
183+ $ "Shader creation failed for { Surface . GraphicsDevice . BackendType } backend. " +
184+ $ "This might be due to missing native dependencies or backend compatibility issues. " +
185+ $ "Original error: { ex . GetType ( ) . Name } : { ex . Message } ", ex ) ;
154186 }
155187
156188 ResourceLayout modelMatrixLayout = factory . CreateResourceLayout (
0 commit comments