mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-01-09 21:20:14 +01:00
mesa/ARB_fp: Drop an extra enum for fog mode.
Reviewed-by: Alyssa Rosenzweig <alyssa@rosenzweig.io> Reviewed-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/23111>
This commit is contained in:
parent
66951679f2
commit
07c93cbdb0
5 changed files with 15 additions and 23 deletions
|
|
@ -133,15 +133,11 @@ _mesa_parse_arb_fragment_program(struct gl_context* ctx, GLenum target,
|
|||
* there's no hardware that wants to do fog in a discrete stage separate
|
||||
* from the fragment shader.
|
||||
*/
|
||||
if (state.option.Fog != OPTION_NONE) {
|
||||
static const GLenum fog_modes[4] = {
|
||||
GL_NONE, GL_EXP, GL_EXP2, GL_LINEAR
|
||||
};
|
||||
|
||||
if (state.option.Fog != FOG_NONE) {
|
||||
/* XXX: we should somehow recompile this to remove clamping if disabled
|
||||
* On the ATI driver, this is unclampled if fragment clamping is disabled
|
||||
*/
|
||||
_mesa_append_fog_code(ctx, program, fog_modes[state.option.Fog], GL_TRUE);
|
||||
_mesa_append_fog_code(ctx, program, state.option.Fog, GL_TRUE);
|
||||
}
|
||||
|
||||
#if DEBUG_FP
|
||||
|
|
|
|||
|
|
@ -87,17 +87,17 @@ _mesa_ARBfp_parse_option(struct asm_parser_state *state, const char *option)
|
|||
option += 4;
|
||||
|
||||
if (strcmp(option, "exp") == 0) {
|
||||
fog_option = OPTION_FOG_EXP;
|
||||
fog_option = FOG_EXP;
|
||||
} else if (strcmp(option, "exp2") == 0) {
|
||||
fog_option = OPTION_FOG_EXP2;
|
||||
fog_option = FOG_EXP2;
|
||||
} else if (strcmp(option, "linear") == 0) {
|
||||
fog_option = OPTION_FOG_LINEAR;
|
||||
fog_option = FOG_LINEAR;
|
||||
} else {
|
||||
/* invalid option */
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (state->option.Fog == OPTION_NONE) {
|
||||
if (state->option.Fog == FOG_NONE) {
|
||||
state->option.Fog = fog_option;
|
||||
return 1;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -208,7 +208,7 @@ struct asm_parser_state {
|
|||
|
||||
struct {
|
||||
unsigned PositionInvariant:1;
|
||||
unsigned Fog:2;
|
||||
unsigned Fog:2; /* gl_fog_mode */
|
||||
unsigned PrecisionHint:2;
|
||||
unsigned DrawBuffers:1;
|
||||
unsigned Shadow:1;
|
||||
|
|
@ -223,10 +223,6 @@ struct asm_parser_state {
|
|||
} fragment;
|
||||
};
|
||||
|
||||
#define OPTION_NONE 0
|
||||
#define OPTION_FOG_EXP 1
|
||||
#define OPTION_FOG_EXP2 2
|
||||
#define OPTION_FOG_LINEAR 3
|
||||
#define OPTION_NICEST 1
|
||||
#define OPTION_FASTEST 2
|
||||
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog)
|
|||
*
|
||||
* \param ctx The GL context
|
||||
* \param fprog Fragment program that fog instructions will be appended to.
|
||||
* \param fog_mode Fog mode. One of \c GL_EXP, \c GL_EXP2, or \c GL_LINEAR.
|
||||
* \param fog_mode Fog mode. One of \c FOG_EXP, \c FOG_EXP2, or \c FOG_LINEAR.
|
||||
* \param saturate True if writes to color outputs should be clamped to [0, 1]
|
||||
*
|
||||
* \note
|
||||
|
|
@ -245,7 +245,7 @@ _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog)
|
|||
*/
|
||||
void
|
||||
_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
||||
GLenum fog_mode, GLboolean saturate)
|
||||
enum gl_fog_mode fog_mode, GLboolean saturate)
|
||||
{
|
||||
static const gl_state_index16 fogPStateOpt[STATE_LENGTH]
|
||||
= { STATE_FOG_PARAMS_OPTIMIZED, 0, 0 };
|
||||
|
|
@ -258,7 +258,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
|||
GLint fogPRefOpt, fogColorRef; /* state references */
|
||||
GLuint colorTemp, fogFactorTemp; /* temporary registerss */
|
||||
|
||||
if (fog_mode == GL_NONE) {
|
||||
if (fog_mode == FOG_NONE) {
|
||||
_mesa_problem(ctx, "_mesa_append_fog_code() called for fragment program"
|
||||
" with fog_mode == GL_NONE");
|
||||
return;
|
||||
|
|
@ -313,7 +313,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
|||
|
||||
/* emit instructions to compute fog blending factor */
|
||||
/* this is always clamped to [0, 1] regardless of fragment clamping */
|
||||
if (fog_mode == GL_LINEAR) {
|
||||
if (fog_mode == FOG_LINEAR) {
|
||||
/* MAD fogFactorTemp.x, fragment.fogcoord.x, fogPRefOpt.x, fogPRefOpt.y; */
|
||||
inst->Opcode = OPCODE_MAD;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
|
|
@ -332,7 +332,7 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
|||
inst++;
|
||||
}
|
||||
else {
|
||||
assert(fog_mode == GL_EXP || fog_mode == GL_EXP2);
|
||||
assert(fog_mode == FOG_EXP || fog_mode == FOG_EXP2);
|
||||
/* fogPRefOpt.z = d/ln(2), fogPRefOpt.w = d/sqrt(ln(2) */
|
||||
/* EXP: MUL fogFactorTemp.x, fogPRefOpt.z, fragment.fogcoord.x; */
|
||||
/* EXP2: MUL fogFactorTemp.x, fogPRefOpt.w, fragment.fogcoord.x; */
|
||||
|
|
@ -343,12 +343,12 @@ _mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
|||
inst->SrcReg[0].File = PROGRAM_STATE_VAR;
|
||||
inst->SrcReg[0].Index = fogPRefOpt;
|
||||
inst->SrcReg[0].Swizzle
|
||||
= (fog_mode == GL_EXP) ? SWIZZLE_ZZZZ : SWIZZLE_WWWW;
|
||||
= (fog_mode == FOG_EXP) ? SWIZZLE_ZZZZ : SWIZZLE_WWWW;
|
||||
inst->SrcReg[1].File = PROGRAM_INPUT;
|
||||
inst->SrcReg[1].Index = VARYING_SLOT_FOGC;
|
||||
inst->SrcReg[1].Swizzle = SWIZZLE_XXXX;
|
||||
inst++;
|
||||
if (fog_mode == GL_EXP2) {
|
||||
if (fog_mode == FOG_EXP2) {
|
||||
/* MUL fogFactorTemp.x, fogFactorTemp.x, fogFactorTemp.x; */
|
||||
inst->Opcode = OPCODE_MUL;
|
||||
inst->DstReg.File = PROGRAM_TEMPORARY;
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ _mesa_insert_mvp_code(struct gl_context *ctx, struct gl_program *vprog);
|
|||
|
||||
extern void
|
||||
_mesa_append_fog_code(struct gl_context *ctx, struct gl_program *fprog,
|
||||
GLenum fog_mode, GLboolean saturate);
|
||||
enum gl_fog_mode fog_mode, GLboolean saturate);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue