forked from eden-emu/eden
		
	glsl: Conditionally use fine/coarse derivatives based on device support
This commit is contained in:
		
							parent
							
								
									4e73fdbd0f
								
							
						
					
					
						commit
						bc50a9ef20
					
				
					 4 changed files with 29 additions and 4 deletions
				
			
		|  | @ -395,6 +395,9 @@ void EmitContext::SetupExtensions() { | |||
|     if (info.uses_typeless_image_reads || info.uses_typeless_image_writes) { | ||||
|         header += "#extension GL_EXT_shader_image_load_formatted : enable\n"; | ||||
|     } | ||||
|     if (info.uses_derivatives && profile.support_gl_derivative_control) { | ||||
|         header += "#extension GL_ARB_derivative_control : enable\n"; | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void EmitContext::DefineConstantBuffers(Bindings& bindings) { | ||||
|  |  | |||
|  | @ -180,18 +180,38 @@ void EmitFSwizzleAdd(EmitContext& ctx, IR::Inst& inst, std::string_view op_a, st | |||
| } | ||||
| 
 | ||||
| void EmitDPdxFine(EmitContext& ctx, IR::Inst& inst, std::string_view op_a) { | ||||
|     ctx.AddF32("{}=dFdxFine({});", inst, op_a); | ||||
|     if (ctx.profile.support_gl_derivative_control) { | ||||
|         ctx.AddF32("{}=dFdxFine({});", inst, op_a); | ||||
|     } else { | ||||
|         LOG_WARNING(Shader_GLSL, "Device does not support dFdxFine, fallback to dFdx"); | ||||
|         ctx.AddF32("{}=dFdx({});", inst, op_a); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void EmitDPdyFine(EmitContext& ctx, IR::Inst& inst, std::string_view op_a) { | ||||
|     ctx.AddF32("{}=dFdyFine({});", inst, op_a); | ||||
|     if (ctx.profile.support_gl_derivative_control) { | ||||
|         ctx.AddF32("{}=dFdyFine({});", inst, op_a); | ||||
|     } else { | ||||
|         LOG_WARNING(Shader_GLSL, "Device does not support dFdyFine, fallback to dFdy"); | ||||
|         ctx.AddF32("{}=dFdy({});", inst, op_a); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void EmitDPdxCoarse(EmitContext& ctx, IR::Inst& inst, std::string_view op_a) { | ||||
|     ctx.AddF32("{}=dFdxCoarse({});", inst, op_a); | ||||
|     if (ctx.profile.support_gl_derivative_control) { | ||||
|         ctx.AddF32("{}=dFdxCoarse({});", inst, op_a); | ||||
|     } else { | ||||
|         LOG_WARNING(Shader_GLSL, "Device does not support dFdxCoarse, fallback to dFdx"); | ||||
|         ctx.AddF32("{}=dFdx({});", inst, op_a); | ||||
|     } | ||||
| } | ||||
| 
 | ||||
| void EmitDPdyCoarse(EmitContext& ctx, IR::Inst& inst, std::string_view op_a) { | ||||
|     ctx.AddF32("{}=dFdyCoarse({});", inst, op_a); | ||||
|     if (ctx.profile.support_gl_derivative_control) { | ||||
|         ctx.AddF32("{}=dFdyCoarse({});", inst, op_a); | ||||
|     } else { | ||||
|         LOG_WARNING(Shader_GLSL, "Device does not support dFdyCoarse, fallback to dFdy"); | ||||
|         ctx.AddF32("{}=dFdy({});", inst, op_a); | ||||
|     } | ||||
| } | ||||
| } // namespace Shader::Backend::GLSL
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ameerj
						ameerj