22 #include "wine/port.h" 37 #define ATIFS_CONST_BUMPMAT(i) (GL_CON_0_ATI + i) 38 #define ATIFS_CONST_STAGE(i) (GL_CON_0_ATI + i) 39 #define ATIFS_CONST_TFACTOR GL_CON_6_ATI 78 default:
return "Unexpected modifier\n";
88 return "GL_2X_BIT_ATI";
90 return "GL_COMP_BIT_ATI";
92 return "GL_NEGATE_BIT_ATI";
94 return "GL_BIAS_BIT_ATI";
97 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI";
99 return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI";
101 return "GL_2X_BIT_ATI | GL_BIAS_BIT_ATI";
103 return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
105 return "GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
107 return "GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
110 return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
112 return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
114 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
116 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
119 return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
122 return "Unexpected argmod combination\n";
143 case GL_ZERO:
return "GL_ZERO";
144 case GL_ONE:
return "GL_ONE";
148 default:
return "Unknown register\n";
158 default:
return "unknown swizzle";
164 case GL_NONE:
return "GL_NONE";
165 case GL_RED:
return "GL_RED";
167 case GL_BLUE:
return "GL_BLUE";
169 default:
return "unknown argrep";
186 default:
return "unexpected op";
192 case GL_NONE:
return "GL_NONE";
200 default:
return "Unexpected writemask";
223 TRACE(
"glAlphaFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s)\n",
debug_op(
op),
debug_register(
dst),
debug_dstmod(
dstMod),
228 TRACE(
"glColorFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n",
debug_op(
op),
debug_register(
dst),
242 TRACE(
"glAlphaFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n",
debug_op(
op),
debug_register(
dst),
debug_dstmod(
dstMod),
251 TRACE(
"glColorFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n",
debug_op(
op),
debug_register(
dst),
310 FIXME(
"Unknown source argument %d\n",
arg);
327 int lowest_read = -1;
328 int lowest_write = -1;
332 memset(tex_used, 0,
sizeof(tex_used));
338 if(lowest_read == -1 &&
355 if(lowest_read == -1)
return GL_NONE;
357 if(lowest_write >= lowest_read) {
358 FIXME(
"Temp register read before being written\n");
361 if(lowest_write == -1) {
363 FIXME(
"Temp register read without being written\n");
365 }
else if(lowest_write >= 1) {
375 for(
i = 1;
i < 6;
i++) {
381 FIXME(
"Could not find a register for the temporary register\n");
445 ERR(
"Unsupported color fixup.\n");
477 GLuint dstmod, argmod0, argmod1, argmod2, argmodextra;
485 ERR(
"Failed to generate a GL_ATI_fragment_shader shader id\n");
489 checkGLcall(
"GL_EXTCALL(glBindFragmentShaderATI(ret))");
491 TRACE(
"glBeginFragmentShaderATI()\n");
493 checkGLcall(
"GL_EXTCALL(glBeginFragmentShaderATI())");
496 for (stage = 0; stage < gl_info->
limits.textures; ++stage)
506 TRACE(
"glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, GL_SWIZZLE_STR_ATI)\n",
518 TRACE(
"glPassTexCoordATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
526 for (stage = 0; stage < gl_info->
limits.textures; ++stage)
528 GLuint argmodextra_x, argmodextra_y;
537 fixup =
op[stage].color_fixup;
540 FIXME(
"Swizzles not implemented\n");
577 for (stage = 0; stage < gl_info->
limits.textures; ++stage)
596 TRACE(
"glSampleMapATI(GL_REG_%d_ATI, GL_REG_%d_ATI, GL_SWIZZLE_STR_ATI)\n",
602 TRACE(
"glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
631 if(tmparg ==
GL_NONE)
continue;
657 FIXME(
"Constant %u already used.\n", stage);
664 switch (
op[stage].cop)
673 arg1, rep1, argmod1);
686 arg2, rep2, argmod2);
699 arg2, rep2, argmodextra | argmod2);
706 arg2, rep2, argmod2);
716 arg1, rep1, argmodextra,
717 arg1, rep1, argmod1);
738 arg2, rep2, argmod2);
746 arg1, rep1, argmod1);
756 argmodextra = argmod1;
760 arg1, rep1, argmod1);
768 argmodextra = argmod1;
771 arg1, rep1, argmodextra,
785 arg0, rep0, argmod0);
792 arg2, rep2, argmod2);
795 default:
FIXME(
"Unhandled color operation %d on stage %d\n",
op[stage].cop, stage);
805 switch (
op[stage].aop)
928 ERR(
"Application uses an invalid alpha operation\n");
931 default:
FIXME(
"Unhandled alpha operation %d on stage %d\n",
op[stage].aop, stage);
936 FIXME(
"Texture factor constant already used.\n");
946 TRACE(
"glEndFragmentShaderATI()\n");
948 checkGLcall(
"GL_EXTCALL(glEndFragmentShaderATI())");
964 checkGLcall(
"glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, &color.r)");
988 mat[0][0] = (
mat[0][0] + 1.0f) * 0.5
f;
989 mat[1][0] = (
mat[1][0] + 1.0f) * 0.5
f;
990 mat[0][1] = (
mat[0][1] + 1.0f) * 0.5
f;
991 mat[1][1] = (
mat[1][1] + 1.0f) * 0.5
f;
993 checkGLcall(
"glSetFragmentShaderConstantATI(ATIFS_CONST_BUMPMAT(stage), mat)");
1009 checkGLcall(
"glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), &color.r)");
1030 if (!(new_desc = heap_alloc_zero(
sizeof(*new_desc))))
1032 ERR(
"Out of memory\n");
1036 for (
i = 0;
i < d3d_info->
limits.ffp_blend_stages; ++
i)
1046 TRACE(
"Allocated fixed function replacement shader descriptor %p.\n", new_desc);
1053 for (
i = 0;
i <
desc->num_textures_used; ++
i)
1055 mapped_stage =
context->tex_unit_map[
i];
1071 switch (
desc->constants[
i])
1086 ERR(
"Unexpected constant type %u.\n",
desc->constants[
i]);
1100 WARN(
"sRGB writes are not supported by this fragment pipe.\n");
1324 if (!(priv = heap_alloc_zero(
sizeof(*priv))))
1338 checkGLcall(
"glDeleteFragmentShaderATI(entry->shader)");
1364 if (!(priv = heap_alloc_zero(
sizeof(*priv))))
1366 context->fragment_pipe_data = priv;
DWORD MaxTextureBlendStages
#define STATE_TEXTURESTAGE(stage, num)
static DWORD atifs_get_emul_mask(const struct wined3d_gl_info *gl_info)
struct mke2fs_defaults settings[]
struct wine_rb_tree fragment_shaders
void state_shademode(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2Mod
static void wrap_op3(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod, GLuint arg3, GLuint arg3Rep, GLuint arg3Mod)
const struct atifs_ffp_desc * last_shader
static const char * debug_dstmod(GLuint mod)
void state_fogstartend(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
struct opengl_funcs gl_ops
#define WINED3D_FRAGMENT_CAP_PROJ_CONTROL
static void atifs_free_context_data(struct wined3d_context *context)
#define WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA
#define WINED3DTA_CONSTANT
void context_active_texture(struct wined3d_context *context, const struct wined3d_gl_info *gl_info, unsigned int unit)
#define WINED3DTEXOPCAPS_DISABLE
#define WINED3DTEXOPCAPS_BLENDCURRENTALPHA
#define ATIFS_CONST_BUMPMAT(i)
#define WINED3DTEXOPCAPS_ADDSIGNED
static void atifs_free(struct wined3d_device *device)
#define WINED3DTEXOPCAPS_MODULATE
static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *cb_ctx)
GLuint GLuint GLuint dstMod
#define GL_QUARTER_BIT_ATI
#define GL_FRAGMENT_SHADER_ATI
#define WINED3DTEXOPCAPS_ADDSIGNED2X
#define WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA
static BOOL is_same_fixup(struct color_fixup_desc f1, struct color_fixup_desc f2)
static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)
#define WINED3DTEXOPCAPS_ADDSMOOTH
static const char * debug_register(GLuint reg)
#define WINED3DTA_COMPLEMENT
static void wrap_op1(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod)
#define WINED3DTEXOPCAPS_SELECTARG2
static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const struct wined3d_gl_info *gl_info, enum atifs_constant_value *constants)
void state_alpha_test(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
void texture_activate_dimensions(const struct wined3d_texture *texture, const struct wined3d_gl_info *gl_info)
#define WINED3DTA_CURRENT
#define WINED3DTEXOPCAPS_LERP
#define WINED3DTEXOPCAPS_BLENDFACTORALPHA
unsigned short x_sign_fixup
static BOOL isStateDirty(const struct wined3d_context *context, DWORD state)
#define GL_SWIZZLE_STR_ATI
void state_fogcolor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2
const struct fragment_pipeline atifs_fragment_pipeline
static const char * debug_argmod(GLuint mod)
static void atifs_stage_constant(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void set_tex_op_atifs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define WINED3DPMISCCAPS_PERSTAGECONSTANT
static BOOL op_reads_texture(const struct texture_stage_op *op)
static BOOL atifs_alloc_context_data(struct wined3d_context *context)
#define WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR
#define ATIFS_CONST_TFACTOR
GLuint GLuint GLuint GLuint arg1
static const WCHAR desc[]
void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *desc)
#define WINED3DPMISCCAPS_TSSARGTEMP
static void atifs_enable(const struct wined3d_gl_info *gl_info, BOOL enable)
#define WINED3DTA_TEXTURE
static const struct color_fixup_desc color_fixup_rg
static void atifs_srgbwriteenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define WINED3DTEXOPCAPS_DOTPRODUCT3
#define GL_EIGHTH_BIT_ATI
void sampler_texdim(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
static void wine_rb_init(struct wine_rb_tree *tree, wine_rb_compare_func_t compare)
unsigned short y_sign_fixup
#define WINED3DTA_SELECTMASK
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3
static void * atifs_alloc(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv)
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM
#define WINED3DTEXOPCAPS_MODULATE4X
const struct ffp_frag_desc * find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders, const struct ffp_frag_settings *settings)
#define WINED3DTEXOPCAPS_SELECTARG1
#define WINE_RB_ENTRY_VALUE(element, type, field)
static const struct color_fixup_desc color_fixup_rgba
#define WINED3DTA_DIFFUSE
#define WINED3DTA_SPECULAR
#define WINED3DTEXOPCAPS_MULTIPLYADD
static BOOL is_identity_fixup(struct color_fixup_desc fixup)
GLuint GLuint GLuint GLuint GLuint arg1Rep
static const struct StateEntryTemplate atifs_fragmentstate_template[]
#define WINED3DTA_TFACTOR
static const char * debug_op(GLuint op)
#define GL_SATURATE_BIT_ATI
DWORD MaxSimultaneousTextures
static BOOL op_reads_tfactor(const struct texture_stage_op *op)
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg2Rep
static void wine_rb_destroy(struct wine_rb_tree *tree, wine_rb_traverse_func_t *callback, void *context)
static void wrap_op2(const struct wined3d_gl_info *gl_info, GLuint op, GLuint dst, GLuint dstMask, GLuint dstMod, GLuint arg1, GLuint arg1Rep, GLuint arg1Mod, GLuint arg2, GLuint arg2Rep, GLuint arg2Mod)
static void atifs_color_fixup(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup, GLuint reg)
static const char * debug_mask(GLuint mask)
static void atifs_get_caps(const struct wined3d_gl_info *gl_info, struct fragment_caps *caps)
static void atifs_tfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define WINED3D_UNMAPPED_STAGE
static const char * debug_rep(GLuint rep)
unsigned int num_textures_used
void state_nop(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define STATE_SAMPLER(num)
static void set_bumpmat(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader)
GLuint GLuint GLuint GLuint GLuint GLuint arg1Mod
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3Mod
#define WINED3DTEXOPCAPS_MODULATE2X
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
struct wined3d_d3d_limits limits
static void textransform(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define WINED3D_HIGHEST_TEXTURE_STATE
#define GL_EXT_EMUL_EXT_FOG_COORD
void state_fogdensity(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
int wined3d_ffp_frag_program_key_compare(const void *key, const struct wine_rb_entry *entry)
#define WINED3DTEXOPCAPS_SUBTRACT
#define GL_SWIZZLE_STQ_DQ_ATI
#define WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA
#define ATIFS_CONST_STAGE(i)
#define WINED3DTA_ALPHAREPLICATE
WINE_DECLARE_DEBUG_CHANNEL(d3d)
void gen_ffp_frag_op(const struct wined3d_context *context, const struct wined3d_state *state, struct ffp_frag_settings *settings, BOOL ignore_textype)
#define GL_SWIZZLE_STQ_ATI
void state_fog_fragpart(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
#define GL_SWIZZLE_STR_DR_ATI
static const char * debug_swizzle(GLuint swizzle)
#define GL_EXT_EMUL_ARB_MULTITEXTURE
#define GL_SECONDARY_INTERPOLATOR_ATI
GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint GLuint arg3Rep
struct wined3d_gl_limits limits
static BOOL op_reads_constant(const struct texture_stage_op *op)
struct ffp_frag_desc parent
#define WINED3DTEXOPCAPS_BLENDTEXTUREALPHA
#define WINED3DTEXOPCAPS_BUMPENVMAP
static void wined3d_color_from_d3dcolor(struct wined3d_color *wined3d_color, DWORD d3d_color)
static GLuint register_for_arg(DWORD arg, const struct wined3d_gl_info *gl_info, unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
#define WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR
static BOOL heap_free(void *mem)
#define GL_NEGATE_BIT_ATI
#define WINED3DTEXOPCAPS_ADD
static const struct color_fixup_desc color_fixup_rgl
static GLuint find_tmpreg(const struct texture_stage_op op[MAX_TEXTURES])
enum atifs_constant_value constants[MAX_TEXTURES]