Handle shader compilation error
This commit is contained in:
@@ -321,13 +321,6 @@ void gpu_disable_scissor() {
|
||||
}
|
||||
|
||||
void gpu_set_pipeline_internal(gpu_pipeline_t *pipeline) {
|
||||
for (int i = 0; i < GPU_MAX_TEXTURES; ++i) {
|
||||
current_textures[i] = NULL;
|
||||
}
|
||||
if (pipeline->impl.pipeline == NULL) {
|
||||
return;
|
||||
}
|
||||
current_pipeline = pipeline;
|
||||
id<MTLRenderPipelineState> pipe = (__bridge id<MTLRenderPipelineState>)pipeline->impl.pipeline;
|
||||
[command_encoder setRenderPipelineState:pipe];
|
||||
id<MTLDepthStencilState> depth_state = (__bridge id<MTLDepthStencilState>)pipeline->impl.depth;
|
||||
@@ -423,6 +416,11 @@ void gpu_pipeline_destroy_internal(gpu_pipeline_t *pipeline) {
|
||||
}
|
||||
|
||||
void gpu_pipeline_compile(gpu_pipeline_t *pipeline) {
|
||||
if (pipeline->vertex_shader->impl.length == 0 || pipeline->fragment_shader->impl.length == 0) {
|
||||
// Shader compilation error
|
||||
return;
|
||||
}
|
||||
|
||||
id<MTLDevice> device = get_metal_device();
|
||||
NSError *error = nil;
|
||||
id<MTLLibrary> library = [device newLibraryWithSource:[[NSString alloc] initWithBytes:pipeline->vertex_shader->impl.source length:pipeline->vertex_shader->impl.length encoding:NSUTF8StringEncoding] options:nil error:&error];
|
||||
|
||||
@@ -1018,6 +1018,10 @@ void gpu_create_shaders_from_kong(char *kong, char **vs, char **fs, int *vs_size
|
||||
if (kong_error) {
|
||||
console_info("Warning: Shader compilation failed");
|
||||
free(tokens.t);
|
||||
#if defined(__APPLE__)
|
||||
*vs = "";
|
||||
*fs = "";
|
||||
#endif
|
||||
return;
|
||||
}
|
||||
allocate_globals();
|
||||
|
||||
@@ -73,6 +73,9 @@ void gpu_begin(gpu_texture_t **targets, int count, gpu_texture_t *depth_buffer,
|
||||
}
|
||||
|
||||
void gpu_draw() {
|
||||
if (current_pipeline == NULL || current_pipeline->impl.pipeline == NULL) {
|
||||
return;
|
||||
}
|
||||
gpu_constant_buffer_unlock(&constant_buffer);
|
||||
gpu_set_constant_buffer(&constant_buffer, constant_buffer_index * GPU_CONSTANT_BUFFER_SIZE, GPU_CONSTANT_BUFFER_SIZE);
|
||||
gpu_draw_internal();
|
||||
@@ -294,13 +297,13 @@ void gpu_texture_destroy(gpu_texture_t *texture) {
|
||||
}
|
||||
|
||||
void gpu_set_pipeline(gpu_pipeline_t *pipeline) {
|
||||
current_pipeline = pipeline;
|
||||
for (int i = 0; i < GPU_MAX_TEXTURES; ++i) {
|
||||
current_textures[i] = NULL;
|
||||
}
|
||||
if (pipeline->impl.pipeline == NULL) {
|
||||
return;
|
||||
}
|
||||
current_pipeline = pipeline;
|
||||
gpu_set_pipeline_internal(pipeline);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user