forked from eden-emu/eden
		
	glsl: Clamp shared mem size to GL_MAX_COMPUTE_SHARED_MEMORY_SIZE
This commit is contained in:
		
							parent
							
								
									ac0c2f8edc
								
							
						
					
					
						commit
						a23f05c215
					
				
					 3 changed files with 12 additions and 2 deletions
				
			
		|  | @ -218,8 +218,15 @@ std::string EmitGLSL(const Profile& profile, const RuntimeInfo& runtime_info, IR | |||
|     const std::string version{fmt::format("#version 450{}\n", GlslVersionSpecifier(ctx))}; | ||||
|     ctx.header.insert(0, version); | ||||
|     if (program.shared_memory_size > 0) { | ||||
|         ctx.header += | ||||
|             fmt::format("shared uint smem[{}];", Common::DivCeil(program.shared_memory_size, 4U)); | ||||
|         const auto requested_size{program.shared_memory_size}; | ||||
|         const auto max_size{profile.gl_max_compute_smem_size}; | ||||
|         const bool needs_clamp{requested_size > max_size}; | ||||
|         if (needs_clamp) { | ||||
|             LOG_WARNING(Shader_GLSL, "Requested shared memory size ({}) exceeds device limit ({})", | ||||
|                         requested_size, max_size); | ||||
|         } | ||||
|         const auto smem_size{needs_clamp ? max_size : requested_size}; | ||||
|         ctx.header += fmt::format("shared uint smem[{}];", Common::DivCeil(smem_size, 4U)); | ||||
|     } | ||||
|     ctx.header += "void main(){\n"; | ||||
|     if (program.local_memory_size > 0) { | ||||
|  |  | |||
|  | @ -67,6 +67,8 @@ struct Profile { | |||
|     bool has_gl_precise_bug{}; | ||||
|     /// Ignores SPIR-V ordered vs unordered using GLSL semantics
 | ||||
|     bool ignore_nan_fp_comparisons{}; | ||||
| 
 | ||||
|     u32 gl_max_compute_smem_size{}; | ||||
| }; | ||||
| 
 | ||||
| } // namespace Shader
 | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 ameerj
						ameerj