aras-p / glsl-optimizer

GLSL optimizer based on Mesa's GLSL compiler. Used to be used in Unity for mobile shader optimization.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Precision not output for sampler2DArray

C0lumbo opened this issue · comments

In the function ir_print_glsl_visitor::print_precision the following block of code skips writing the default lowp precision when possible:

// skip precision for samplers that end up being lowp (default anyway) or undefined;
// except always emit it for shadowmap samplers (some drivers don't implement
// default EXT_shadow_samplers precision) and 3D textures (they always require precision)
if (type && type->is_sampler() && !type->sampler_shadow && !type->sampler_array && !(type->sampler_dimensionality > GLSL_SAMPLER_DIM_2D))
{
	if (prec == glsl_precision_low || prec == glsl_precision_undefined)
		return;
}

This wrongly skips writing precision for 2D array textures. The fixed conditional should also check for sampler_array:

if (type && type->is_sampler() && !type->sampler_shadow && !type->sampler_array && !(type->sampler_dimensionality > GLSL_SAMPLER_DIM_2D))