Fix #107159: Resolve wireframe depth issue in Metal #108453

Merged
Jeroen Bakker merged 1 commits from Jason-Fielder/blender:Fix_107159 into blender-v3.6-release 2023-06-12 08:37:57 +02:00
2 changed files with 10 additions and 2 deletions

View File

@ -3113,6 +3113,14 @@ std::string MSLGeneratorInterface::generate_msl_fragment_input_population()
<< this->vertex_output_varyings[0].name << ";" << std::endl;
}
/* Assign default gl_FragDepth.
* If gl_FragDepth is used, it should default to the original depth value. Resolves #107159 where
* overlay_wireframe_frag may not write to gl_FragDepth. */
if (this->uses_gl_FragDepth) {
out << "\t" << shader_stage_inst_name << ".gl_FragDepth = " << shader_stage_inst_name
<< ".gl_FragCoord.z;" << std::endl;
}
/* NOTE: We will only assign to the intersection of the vertex output and fragment input.
* Fragment input represents varying variables which are declared (but are not necessarily
* used). The Vertex out defines the set which is passed into the fragment shader, which

View File

@ -1551,7 +1551,7 @@ void gpu::MTLTexture::read_internal(int mip,
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder dispatchThreads:MTLSizeMake(width, height, 1) /* Width, Height, Layer */
threadsPerThreadgroup:MTLSizeMake(8, 8, 1)];
@ -1601,7 +1601,7 @@ void gpu::MTLTexture::read_internal(int mip,
MTLComputeState &cs = ctx->main_command_buffer.get_compute_state();
cs.bind_pso(pso);
cs.bind_compute_bytes(&params, sizeof(params), 0);
cs.bind_compute_buffer(destination_buffer, 0, 1);
cs.bind_compute_buffer(destination_buffer, 0, 1, true);
cs.bind_compute_texture(read_texture, 0);
[compute_encoder
dispatchThreads:MTLSizeMake(width, height, depth) /* Width, Height, Layer */