mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-08 06:58:05 +02:00
mesa: implement glGetShaderPrecisionFormat()
Drivers should override the default range/precision info as needed. No drivers do this yet.
This commit is contained in:
parent
34613c66ac
commit
3ee60a3558
3 changed files with 68 additions and 5 deletions
|
|
@ -526,6 +526,16 @@ init_program_limits(GLenum type, struct gl_program_constants *prog)
|
|||
prog->MaxNativeTemps = 0;
|
||||
prog->MaxNativeAddressRegs = 0;
|
||||
prog->MaxNativeParameters = 0;
|
||||
|
||||
/* Set GLSL datatype range/precision info assuming IEEE float values.
|
||||
* Drivers should override these defaults as needed.
|
||||
*/
|
||||
prog->MediumFloat.RangeMin = 127;
|
||||
prog->MediumFloat.RangeMax = 127;
|
||||
prog->MediumFloat.Precision = 23;
|
||||
prog->LowFloat = prog->HighFloat = prog->MediumFloat;
|
||||
/* assume ints are stored as floats for now */
|
||||
prog->LowInt = prog->MediumInt = prog->HighInt = prog->MediumFloat;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -2548,6 +2548,17 @@ struct gl_framebuffer
|
|||
};
|
||||
|
||||
|
||||
/**
|
||||
* Precision info for shader datatypes. See glGetShaderPrecisionFormat().
|
||||
*/
|
||||
struct gl_precision
|
||||
{
|
||||
GLushort RangeMin; /**< min value exponent */
|
||||
GLushort RangeMax; /**< max value exponent */
|
||||
GLushort Precision; /**< number of mantissa bits */
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Limits for vertex and fragment programs/shaders.
|
||||
*/
|
||||
|
|
@ -2582,6 +2593,9 @@ struct gl_program_constants
|
|||
GLuint MaxGeometryUniformComponents;
|
||||
GLuint MaxGeometryOutputVertices;
|
||||
GLuint MaxGeometryTotalOutputComponents;
|
||||
/* ES 2.0 and GL_ARB_ES2_compatibility */
|
||||
struct gl_precision LowFloat, MediumFloat, HighFloat;
|
||||
struct gl_precision LowInt, MediumInt, HighInt;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -1628,12 +1628,51 @@ void GLAPIENTRY
|
|||
_mesa_GetShaderPrecisionFormat(GLenum shadertype, GLenum precisiontype,
|
||||
GLint* range, GLint* precision)
|
||||
{
|
||||
const struct gl_program_constants *limits;
|
||||
const struct gl_precision *p;
|
||||
GET_CURRENT_CONTEXT(ctx);
|
||||
(void) shadertype;
|
||||
(void) precisiontype;
|
||||
(void) range;
|
||||
(void) precision;
|
||||
_mesa_error(ctx, GL_INVALID_OPERATION, __FUNCTION__);
|
||||
|
||||
switch (shadertype) {
|
||||
case GL_VERTEX_SHADER:
|
||||
limits = &ctx->Const.VertexProgram;
|
||||
break;
|
||||
case GL_FRAGMENT_SHADER:
|
||||
limits = &ctx->Const.FragmentProgram;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetShaderPrecisionFormat(shadertype)");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (precisiontype) {
|
||||
case GL_LOW_FLOAT:
|
||||
p = &limits->LowFloat;
|
||||
break;
|
||||
case GL_MEDIUM_FLOAT:
|
||||
p = &limits->MediumFloat;
|
||||
break;
|
||||
case GL_HIGH_FLOAT:
|
||||
p = &limits->HighFloat;
|
||||
break;
|
||||
case GL_LOW_INT:
|
||||
p = &limits->LowInt;
|
||||
break;
|
||||
case GL_MEDIUM_INT:
|
||||
p = &limits->MediumInt;
|
||||
break;
|
||||
case GL_HIGH_INT:
|
||||
p = &limits->HighInt;
|
||||
break;
|
||||
default:
|
||||
_mesa_error(ctx, GL_INVALID_ENUM,
|
||||
"glGetShaderPrecisionFormat(precisiontype)");
|
||||
return;
|
||||
}
|
||||
|
||||
range[0] = p->RangeMin;
|
||||
range[1] = p->RangeMax;
|
||||
precision[0] = p->Precision;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue