2008-03-22 14:31:52 +01:00
|
|
|
/*
|
|
|
|
* Fixed function pipeline replacement using GL_ATI_fragment_shader
|
|
|
|
*
|
2008-10-18 19:21:20 +02:00
|
|
|
* Copyright 2008 Stefan Dösinger(for CodeWeavers)
|
2008-03-22 14:31:52 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
2012-06-01 16:56:21 +02:00
|
|
|
#include "wine/port.h"
|
2008-03-22 14:31:52 +01:00
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
|
|
|
#include "wined3d_private.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
|
2008-12-03 14:53:43 +01:00
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(d3d);
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2012-12-10 21:54:36 +01:00
|
|
|
/* Context activation for state handlers is done by the caller. */
|
2009-05-14 19:40:56 +02:00
|
|
|
|
2008-04-22 08:18:14 +02:00
|
|
|
/* Some private defines, Constant associations, etc.
|
2008-03-20 18:38:47 +01:00
|
|
|
* Env bump matrix and per stage constant should be independent,
|
2008-04-22 08:18:14 +02:00
|
|
|
* a stage that bump maps can't read the per state constant
|
2008-03-20 18:38:47 +01:00
|
|
|
*/
|
2015-03-26 19:02:41 +01:00
|
|
|
#define ATIFS_CONST_BUMPMAT(i) (GL_CON_0_ATI + i)
|
|
|
|
#define ATIFS_CONST_STAGE(i) (GL_CON_0_ATI + i)
|
|
|
|
#define ATIFS_CONST_TFACTOR GL_CON_6_ATI
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
enum atifs_constant_value
|
|
|
|
{
|
|
|
|
ATIFS_CONSTANT_UNUSED = 0,
|
|
|
|
ATIFS_CONSTANT_BUMP,
|
2015-03-26 19:02:41 +01:00
|
|
|
ATIFS_CONSTANT_TFACTOR,
|
|
|
|
ATIFS_CONSTANT_STAGE,
|
2015-03-23 18:59:10 +01:00
|
|
|
};
|
|
|
|
|
2008-03-22 14:31:52 +01:00
|
|
|
/* GL_ATI_fragment_shader specific fixed function pipeline description. "Inherits" from the common one */
|
|
|
|
struct atifs_ffp_desc
|
|
|
|
{
|
2008-11-07 17:15:29 +01:00
|
|
|
struct ffp_frag_desc parent;
|
2008-03-22 14:31:52 +01:00
|
|
|
GLuint shader;
|
2008-04-23 22:23:57 +02:00
|
|
|
unsigned int num_textures_used;
|
2019-02-20 21:53:57 +01:00
|
|
|
enum atifs_constant_value constants[WINED3D_MAX_TEXTURES];
|
2008-03-22 14:31:52 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
struct atifs_private_data
|
|
|
|
{
|
2009-06-03 10:47:26 +02:00
|
|
|
struct wine_rb_tree fragment_shaders; /* A rb-tree to track fragment pipeline replacement shaders */
|
2008-03-22 14:31:52 +01:00
|
|
|
};
|
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
struct atifs_context_private_data
|
|
|
|
{
|
|
|
|
const struct atifs_ffp_desc *last_shader;
|
|
|
|
};
|
|
|
|
|
2008-03-22 14:31:52 +01:00
|
|
|
static const char *debug_dstmod(GLuint mod) {
|
|
|
|
switch(mod) {
|
|
|
|
case GL_NONE: return "GL_NONE";
|
|
|
|
case GL_2X_BIT_ATI: return "GL_2X_BIT_ATI";
|
|
|
|
case GL_4X_BIT_ATI: return "GL_4X_BIT_ATI";
|
|
|
|
case GL_8X_BIT_ATI: return "GL_8X_BIT_ATI";
|
|
|
|
case GL_HALF_BIT_ATI: return "GL_HALF_BIT_ATI";
|
|
|
|
case GL_QUARTER_BIT_ATI: return "GL_QUARTER_BIT_ATI";
|
|
|
|
case GL_EIGHTH_BIT_ATI: return "GL_EIGHTH_BIT_ATI";
|
|
|
|
case GL_SATURATE_BIT_ATI: return "GL_SATURATE_BIT_ATI";
|
|
|
|
default: return "Unexpected modifier\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debug_argmod(GLuint mod) {
|
|
|
|
switch(mod) {
|
|
|
|
case GL_NONE:
|
|
|
|
return "GL_NONE";
|
|
|
|
|
|
|
|
case GL_2X_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI";
|
|
|
|
case GL_COMP_BIT_ATI:
|
|
|
|
return "GL_COMP_BIT_ATI";
|
|
|
|
case GL_NEGATE_BIT_ATI:
|
|
|
|
return "GL_NEGATE_BIT_ATI";
|
|
|
|
case GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_BIAS_BIT_ATI";
|
|
|
|
|
|
|
|
case GL_2X_BIT_ATI | GL_COMP_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI";
|
|
|
|
case GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI";
|
|
|
|
case GL_2X_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
case GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI:
|
|
|
|
return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
|
|
|
|
case GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
case GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
|
|
|
|
case GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
case GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
case GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
case GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI";
|
|
|
|
|
|
|
|
case GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI:
|
|
|
|
return "GL_2X_BIT_ATI | GL_COMP_BIT_ATI | GL_NEGATE_BIT_ATI | GL_BIAS_BIT_ATI";
|
|
|
|
|
|
|
|
default:
|
|
|
|
return "Unexpected argmod combination\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
static const char *debug_register(GLuint reg) {
|
|
|
|
switch(reg) {
|
|
|
|
case GL_REG_0_ATI: return "GL_REG_0_ATI";
|
|
|
|
case GL_REG_1_ATI: return "GL_REG_1_ATI";
|
|
|
|
case GL_REG_2_ATI: return "GL_REG_2_ATI";
|
|
|
|
case GL_REG_3_ATI: return "GL_REG_3_ATI";
|
|
|
|
case GL_REG_4_ATI: return "GL_REG_4_ATI";
|
|
|
|
case GL_REG_5_ATI: return "GL_REG_5_ATI";
|
|
|
|
|
|
|
|
case GL_CON_0_ATI: return "GL_CON_0_ATI";
|
|
|
|
case GL_CON_1_ATI: return "GL_CON_1_ATI";
|
|
|
|
case GL_CON_2_ATI: return "GL_CON_2_ATI";
|
|
|
|
case GL_CON_3_ATI: return "GL_CON_3_ATI";
|
|
|
|
case GL_CON_4_ATI: return "GL_CON_4_ATI";
|
|
|
|
case GL_CON_5_ATI: return "GL_CON_5_ATI";
|
|
|
|
case GL_CON_6_ATI: return "GL_CON_6_ATI";
|
|
|
|
case GL_CON_7_ATI: return "GL_CON_7_ATI";
|
|
|
|
|
|
|
|
case GL_ZERO: return "GL_ZERO";
|
|
|
|
case GL_ONE: return "GL_ONE";
|
|
|
|
case GL_PRIMARY_COLOR: return "GL_PRIMARY_COLOR";
|
|
|
|
case GL_SECONDARY_INTERPOLATOR_ATI: return "GL_SECONDARY_INTERPOLATOR_ATI";
|
|
|
|
|
|
|
|
default: return "Unknown register\n";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debug_swizzle(GLuint swizzle) {
|
|
|
|
switch(swizzle) {
|
|
|
|
case GL_SWIZZLE_STR_ATI: return "GL_SWIZZLE_STR_ATI";
|
|
|
|
case GL_SWIZZLE_STQ_ATI: return "GL_SWIZZLE_STQ_ATI";
|
|
|
|
case GL_SWIZZLE_STR_DR_ATI: return "GL_SWIZZLE_STR_DR_ATI";
|
|
|
|
case GL_SWIZZLE_STQ_DQ_ATI: return "GL_SWIZZLE_STQ_DQ_ATI";
|
|
|
|
default: return "unknown swizzle";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-08-19 17:43:03 +02:00
|
|
|
static const char *debug_rep(GLuint rep) {
|
|
|
|
switch(rep) {
|
|
|
|
case GL_NONE: return "GL_NONE";
|
|
|
|
case GL_RED: return "GL_RED";
|
|
|
|
case GL_GREEN: return "GL_GREEN";
|
|
|
|
case GL_BLUE: return "GL_BLUE";
|
2012-12-05 09:01:37 +01:00
|
|
|
case GL_ALPHA: return "GL_ALPHA";
|
2008-08-19 17:43:03 +02:00
|
|
|
default: return "unknown argrep";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-09 18:16:14 +01:00
|
|
|
static const char *debug_op(GLuint op) {
|
|
|
|
switch(op) {
|
|
|
|
case GL_MOV_ATI: return "GL_MOV_ATI";
|
|
|
|
case GL_ADD_ATI: return "GL_ADD_ATI";
|
|
|
|
case GL_MUL_ATI: return "GL_MUL_ATI";
|
|
|
|
case GL_SUB_ATI: return "GL_SUB_ATI";
|
|
|
|
case GL_DOT3_ATI: return "GL_DOT3_ATI";
|
|
|
|
case GL_DOT4_ATI: return "GL_DOT4_ATI";
|
|
|
|
case GL_MAD_ATI: return "GL_MAD_ATI";
|
|
|
|
case GL_LERP_ATI: return "GL_LERP_ATI";
|
|
|
|
case GL_CND_ATI: return "GL_CND_ATI";
|
|
|
|
case GL_CND0_ATI: return "GL_CND0_ATI";
|
|
|
|
case GL_DOT2_ADD_ATI: return "GL_DOT2_ADD_ATI";
|
|
|
|
default: return "unexpected op";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static const char *debug_mask(GLuint mask) {
|
|
|
|
switch(mask) {
|
|
|
|
case GL_NONE: return "GL_NONE";
|
|
|
|
case GL_RED_BIT_ATI: return "GL_RED_BIT_ATI";
|
|
|
|
case GL_GREEN_BIT_ATI: return "GL_GREEN_BIT_ATI";
|
|
|
|
case GL_BLUE_BIT_ATI: return "GL_BLUE_BIT_ATI";
|
|
|
|
case GL_RED_BIT_ATI | GL_GREEN_BIT_ATI: return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI";
|
|
|
|
case GL_RED_BIT_ATI | GL_BLUE_BIT_ATI: return "GL_RED_BIT_ATI | GL_BLUE_BIT_ATI";
|
|
|
|
case GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI:return "GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
|
|
|
|
case GL_RED_BIT_ATI | GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI:return "GL_RED_BIT_ATI | GL_GREEN_BIT_ATI | GL_BLUE_BIT_ATI";
|
|
|
|
default: return "Unexpected writemask";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 10:34:01 +02:00
|
|
|
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)
|
|
|
|
{
|
2008-12-09 18:16:14 +01:00
|
|
|
if(dstMask == GL_ALPHA) {
|
|
|
|
TRACE("glAlphaFragmentOp1ATI(%s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod));
|
|
|
|
GL_EXTCALL(glAlphaFragmentOp1ATI(op, dst, dstMod, arg1, arg1Rep, arg1Mod));
|
|
|
|
} else {
|
|
|
|
TRACE("glColorFragmentOp1ATI(%s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
|
|
|
|
debug_mask(dstMask), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod));
|
|
|
|
GL_EXTCALL(glColorFragmentOp1ATI(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 10:34:01 +02:00
|
|
|
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)
|
|
|
|
{
|
2008-12-09 18:16:14 +01:00
|
|
|
if(dstMask == GL_ALPHA) {
|
|
|
|
TRACE("glAlphaFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
|
|
|
|
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod));
|
|
|
|
GL_EXTCALL(glAlphaFragmentOp2ATI(op, dst, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
|
|
|
|
} else {
|
|
|
|
TRACE("glColorFragmentOp2ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
|
|
|
|
debug_mask(dstMask), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
|
|
|
|
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod));
|
|
|
|
GL_EXTCALL(glColorFragmentOp2ATI(op, dst, dstMask, dstMod, arg1, arg1Rep, arg1Mod, arg2, arg2Rep, arg2Mod));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 10:34:01 +02:00
|
|
|
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)
|
|
|
|
{
|
2008-12-09 18:16:14 +01:00
|
|
|
if(dstMask == GL_ALPHA) {
|
|
|
|
/* Leave some free space to fit "GL_NONE, " in to align most alpha and color op lines */
|
|
|
|
TRACE("glAlphaFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
|
|
|
|
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod),
|
|
|
|
debug_register(arg3), debug_rep(arg3Rep), debug_argmod(arg3Mod));
|
|
|
|
GL_EXTCALL(glAlphaFragmentOp3ATI(op, dst, dstMod,
|
|
|
|
arg1, arg1Rep, arg1Mod,
|
|
|
|
arg2, arg2Rep, arg2Mod,
|
|
|
|
arg3, arg3Rep, arg3Mod));
|
|
|
|
} else {
|
|
|
|
TRACE("glColorFragmentOp3ATI(%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s)\n", debug_op(op), debug_register(dst),
|
|
|
|
debug_mask(dstMask), debug_dstmod(dstMod),
|
|
|
|
debug_register(arg1), debug_rep(arg1Rep), debug_argmod(arg1Mod),
|
|
|
|
debug_register(arg2), debug_rep(arg2Rep), debug_argmod(arg2Mod),
|
|
|
|
debug_register(arg3), debug_rep(arg3Rep), debug_argmod(arg3Mod));
|
|
|
|
GL_EXTCALL(glColorFragmentOp3ATI(op, dst, dstMask, dstMod,
|
|
|
|
arg1, arg1Rep, arg1Mod,
|
|
|
|
arg2, arg2Rep, arg2Mod,
|
|
|
|
arg3, arg3Rep, arg3Mod));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-17 10:34:01 +02:00
|
|
|
static GLuint register_for_arg(DWORD arg, const struct wined3d_gl_info *gl_info,
|
2008-11-26 16:14:39 +01:00
|
|
|
unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
|
|
|
|
{
|
2008-03-22 14:31:52 +01:00
|
|
|
GLenum ret;
|
|
|
|
|
|
|
|
if(mod) *mod = GL_NONE;
|
2008-10-08 17:34:51 +02:00
|
|
|
if(arg == ARG_UNUSED)
|
|
|
|
{
|
|
|
|
if (rep) *rep = GL_NONE;
|
|
|
|
return -1; /* This is the marker for unused registers */
|
|
|
|
}
|
2008-03-22 14:31:52 +01:00
|
|
|
|
|
|
|
switch(arg & WINED3DTA_SELECTMASK) {
|
|
|
|
case WINED3DTA_DIFFUSE:
|
|
|
|
ret = GL_PRIMARY_COLOR;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_CURRENT:
|
|
|
|
/* Note that using GL_REG_0_ATI for the passed on register is safe because
|
|
|
|
* texture0 is read at stage0, so in the worst case it is read in the
|
|
|
|
* instruction writing to reg0. Afterwards texture0 is not used any longer.
|
|
|
|
* If we're reading from current
|
|
|
|
*/
|
2010-09-14 13:38:39 +02:00
|
|
|
ret = stage ? GL_REG_0_ATI : GL_PRIMARY_COLOR;
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_TEXTURE:
|
|
|
|
ret = GL_REG_0_ATI + stage;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_TFACTOR:
|
2015-03-26 19:02:41 +01:00
|
|
|
ret = ATIFS_CONST_TFACTOR;
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_SPECULAR:
|
|
|
|
ret = GL_SECONDARY_INTERPOLATOR_ATI;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_TEMP:
|
2008-03-29 00:41:07 +01:00
|
|
|
ret = tmparg;
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DTA_CONSTANT:
|
2015-03-26 19:02:41 +01:00
|
|
|
ret = ATIFS_CONST_STAGE(stage);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unknown source argument %d\n", arg);
|
|
|
|
ret = GL_ZERO;
|
|
|
|
}
|
|
|
|
|
|
|
|
if(arg & WINED3DTA_COMPLEMENT) {
|
|
|
|
if(mod) *mod |= GL_COMP_BIT_ATI;
|
|
|
|
}
|
|
|
|
if(arg & WINED3DTA_ALPHAREPLICATE) {
|
2008-08-19 17:43:03 +02:00
|
|
|
if(rep) *rep = GL_ALPHA;
|
|
|
|
} else {
|
|
|
|
if(rep) *rep = GL_NONE;
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-02-20 21:53:57 +01:00
|
|
|
static GLuint find_tmpreg(const struct texture_stage_op op[WINED3D_MAX_TEXTURES])
|
2008-11-26 16:14:39 +01:00
|
|
|
{
|
2008-03-29 23:55:09 +01:00
|
|
|
int lowest_read = -1;
|
|
|
|
int lowest_write = -1;
|
|
|
|
int i;
|
2019-02-20 21:53:57 +01:00
|
|
|
BOOL tex_used[WINED3D_MAX_TEXTURES];
|
2008-03-29 23:55:09 +01:00
|
|
|
|
|
|
|
memset(tex_used, 0, sizeof(tex_used));
|
2019-02-20 21:53:57 +01:00
|
|
|
for (i = 0; i < WINED3D_MAX_TEXTURES; ++i)
|
2012-01-10 20:37:01 +01:00
|
|
|
{
|
|
|
|
if (op[i].cop == WINED3D_TOP_DISABLE)
|
2008-03-29 23:55:09 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
if(lowest_read == -1 &&
|
|
|
|
(op[i].carg1 == WINED3DTA_TEMP || op[i].carg2 == WINED3DTA_TEMP || op[i].carg0 == WINED3DTA_TEMP ||
|
|
|
|
op[i].aarg1 == WINED3DTA_TEMP || op[i].aarg2 == WINED3DTA_TEMP || op[i].aarg0 == WINED3DTA_TEMP)) {
|
|
|
|
lowest_read = i;
|
|
|
|
}
|
|
|
|
|
2018-03-23 11:44:31 +01:00
|
|
|
if (lowest_write == -1 && op[i].tmp_dst)
|
2008-03-29 23:55:09 +01:00
|
|
|
lowest_write = i;
|
|
|
|
|
|
|
|
if(op[i].carg1 == WINED3DTA_TEXTURE || op[i].carg2 == WINED3DTA_TEXTURE || op[i].carg0 == WINED3DTA_TEXTURE ||
|
|
|
|
op[i].aarg1 == WINED3DTA_TEXTURE || op[i].aarg2 == WINED3DTA_TEXTURE || op[i].aarg0 == WINED3DTA_TEXTURE) {
|
|
|
|
tex_used[i] = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Temp reg not read? We don't need it, return GL_NONE */
|
|
|
|
if(lowest_read == -1) return GL_NONE;
|
|
|
|
|
|
|
|
if(lowest_write >= lowest_read) {
|
2008-04-07 13:01:02 +02:00
|
|
|
FIXME("Temp register read before being written\n");
|
2008-03-29 23:55:09 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if(lowest_write == -1) {
|
|
|
|
/* This needs a test. Maybe we are supposed to return 0.0/0.0/0.0/0.0, or fail drawprim, or whatever */
|
2008-04-07 13:01:02 +02:00
|
|
|
FIXME("Temp register read without being written\n");
|
2008-03-29 23:55:09 +01:00
|
|
|
return GL_REG_1_ATI;
|
|
|
|
} else if(lowest_write >= 1) {
|
|
|
|
/* If we're writing to the temp reg at earliest in stage 1, we can use register 1 for the temp result.
|
|
|
|
* there may be texture data stored in reg 1, but we do not need it any longer since stage 1 already
|
|
|
|
* read it
|
|
|
|
*/
|
|
|
|
return GL_REG_1_ATI;
|
|
|
|
} else {
|
|
|
|
/* Search for a free texture register. We have 6 registers available. GL_REG_0_ATI is already used
|
|
|
|
* for the regular result
|
|
|
|
*/
|
|
|
|
for(i = 1; i < 6; i++) {
|
|
|
|
if(!tex_used[i]) {
|
|
|
|
return GL_REG_0_ATI + i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* What to do here? Report it in ValidateDevice? */
|
|
|
|
FIXME("Could not find a register for the temporary register\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:59:07 +01:00
|
|
|
static const struct color_fixup_desc color_fixup_rg =
|
|
|
|
{
|
|
|
|
1, CHANNEL_SOURCE_X,
|
|
|
|
1, CHANNEL_SOURCE_Y,
|
|
|
|
0, CHANNEL_SOURCE_ONE,
|
|
|
|
0, CHANNEL_SOURCE_ONE
|
|
|
|
};
|
|
|
|
static const struct color_fixup_desc color_fixup_rgl =
|
|
|
|
{
|
|
|
|
1, CHANNEL_SOURCE_X,
|
|
|
|
1, CHANNEL_SOURCE_Y,
|
|
|
|
0, CHANNEL_SOURCE_Z,
|
|
|
|
0, CHANNEL_SOURCE_W
|
|
|
|
};
|
|
|
|
static const struct color_fixup_desc color_fixup_rgba =
|
|
|
|
{
|
|
|
|
1, CHANNEL_SOURCE_X,
|
|
|
|
1, CHANNEL_SOURCE_Y,
|
|
|
|
1, CHANNEL_SOURCE_Z,
|
|
|
|
1, CHANNEL_SOURCE_W
|
|
|
|
};
|
|
|
|
|
|
|
|
static BOOL op_reads_texture(const struct texture_stage_op *op)
|
|
|
|
{
|
|
|
|
return (op->carg0 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| (op->carg1 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| (op->carg2 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| (op->aarg0 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| (op->aarg1 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| (op->aarg2 & WINED3DTA_SELECTMASK) == WINED3DTA_TEXTURE
|
|
|
|
|| op->cop == WINED3D_TOP_BLEND_TEXTURE_ALPHA;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void atifs_color_fixup(const struct wined3d_gl_info *gl_info, struct color_fixup_desc fixup, GLuint reg)
|
|
|
|
{
|
|
|
|
if(is_same_fixup(fixup, color_fixup_rg))
|
|
|
|
{
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_RED_BIT_ATI | GL_GREEN_BIT_ATI, GL_NONE,
|
|
|
|
reg, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI);
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_BLUE_BIT_ATI, GL_NONE,
|
|
|
|
GL_ONE, GL_NONE, GL_NONE);
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_ALPHA, GL_NONE,
|
|
|
|
GL_ONE, GL_NONE, GL_NONE);
|
|
|
|
}
|
|
|
|
else if(is_same_fixup(fixup, color_fixup_rgl))
|
|
|
|
{
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_RED_BIT_ATI | GL_GREEN_BIT_ATI, GL_NONE,
|
|
|
|
reg, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI);
|
|
|
|
}
|
|
|
|
else if (is_same_fixup(fixup, color_fixup_rgba))
|
|
|
|
{
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_NONE, GL_NONE,
|
|
|
|
reg, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI);
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, reg, GL_ALPHA, GL_NONE,
|
|
|
|
reg, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Should not happen - atifs_color_fixup_supported refuses other fixups. */
|
|
|
|
ERR("Unsupported color fixup.\n");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
static BOOL op_reads_tfactor(const struct texture_stage_op *op)
|
|
|
|
{
|
|
|
|
return (op->carg0 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| (op->carg1 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| (op->carg2 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| (op->aarg0 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| (op->aarg1 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| (op->aarg2 & WINED3DTA_SELECTMASK) == WINED3DTA_TFACTOR
|
|
|
|
|| op->cop == WINED3D_TOP_BLEND_FACTOR_ALPHA
|
|
|
|
|| op->aop == WINED3D_TOP_BLEND_FACTOR_ALPHA;
|
|
|
|
}
|
|
|
|
|
2015-03-26 19:02:41 +01:00
|
|
|
static BOOL op_reads_constant(const struct texture_stage_op *op)
|
|
|
|
{
|
|
|
|
return (op->carg0 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT
|
|
|
|
|| (op->carg1 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT
|
|
|
|
|| (op->carg2 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT
|
|
|
|
|| (op->aarg0 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT
|
|
|
|
|| (op->aarg1 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT
|
|
|
|
|| (op->aarg2 & WINED3DTA_SELECTMASK) == WINED3DTA_CONSTANT;
|
|
|
|
}
|
|
|
|
|
2019-02-20 21:53:57 +01:00
|
|
|
static GLuint gen_ati_shader(const struct texture_stage_op op[WINED3D_MAX_TEXTURES],
|
2015-03-23 18:59:10 +01:00
|
|
|
const struct wined3d_gl_info *gl_info, enum atifs_constant_value *constants)
|
2008-11-26 16:14:39 +01:00
|
|
|
{
|
2008-03-22 14:31:52 +01:00
|
|
|
GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1));
|
|
|
|
unsigned int stage;
|
|
|
|
GLuint arg0, arg1, arg2, extrarg;
|
|
|
|
GLuint dstmod, argmod0, argmod1, argmod2, argmodextra;
|
2008-08-19 17:43:03 +02:00
|
|
|
GLuint rep0, rep1, rep2;
|
2008-03-22 14:31:52 +01:00
|
|
|
GLuint swizzle;
|
2008-03-29 23:55:09 +01:00
|
|
|
GLuint tmparg = find_tmpreg(op);
|
2008-03-29 00:41:07 +01:00
|
|
|
GLuint dstreg;
|
2015-03-23 18:59:10 +01:00
|
|
|
BOOL tfactor_used = FALSE;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
|
|
|
if(!ret) {
|
|
|
|
ERR("Failed to generate a GL_ATI_fragment_shader shader id\n");
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
GL_EXTCALL(glBindFragmentShaderATI(ret));
|
|
|
|
checkGLcall("GL_EXTCALL(glBindFragmentShaderATI(ret))");
|
|
|
|
|
|
|
|
TRACE("glBeginFragmentShaderATI()\n");
|
|
|
|
GL_EXTCALL(glBeginFragmentShaderATI());
|
|
|
|
checkGLcall("GL_EXTCALL(glBeginFragmentShaderATI())");
|
|
|
|
|
2008-03-20 18:38:47 +01:00
|
|
|
/* Pass 1: Generate sampling instructions for perturbation maps */
|
2009-10-29 10:37:10 +01:00
|
|
|
for (stage = 0; stage < gl_info->limits.textures; ++stage)
|
2009-10-22 10:09:54 +02:00
|
|
|
{
|
2012-01-10 20:37:01 +01:00
|
|
|
if (op[stage].cop == WINED3D_TOP_DISABLE)
|
|
|
|
break;
|
|
|
|
if (op[stage].cop != WINED3D_TOP_BUMPENVMAP
|
|
|
|
&& op[stage].cop != WINED3D_TOP_BUMPENVMAP_LUMINANCE)
|
|
|
|
continue;
|
2008-03-20 18:38:47 +01:00
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
constants[stage] = ATIFS_CONSTANT_BUMP;
|
|
|
|
|
2008-03-20 18:38:47 +01:00
|
|
|
TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, GL_SWIZZLE_STR_ATI)\n",
|
|
|
|
stage, stage);
|
2018-03-23 11:44:30 +01:00
|
|
|
GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI + stage, GL_TEXTURE0_ARB + stage, GL_SWIZZLE_STR_ATI));
|
|
|
|
if (op[stage + 1].projected == WINED3D_PROJECTION_NONE)
|
2008-08-21 20:47:41 +02:00
|
|
|
swizzle = GL_SWIZZLE_STR_ATI;
|
2018-03-23 11:44:30 +01:00
|
|
|
else if (op[stage + 1].projected == WINED3D_PROJECTION_COUNT4)
|
2008-08-21 20:47:41 +02:00
|
|
|
swizzle = GL_SWIZZLE_STQ_DQ_ATI;
|
2018-03-23 11:44:30 +01:00
|
|
|
else
|
2008-08-23 22:41:51 +02:00
|
|
|
swizzle = GL_SWIZZLE_STR_DR_ATI;
|
2008-08-21 20:47:41 +02:00
|
|
|
TRACE("glPassTexCoordATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
|
|
|
|
stage + 1, stage + 1, debug_swizzle(swizzle));
|
2008-03-20 18:38:47 +01:00
|
|
|
GL_EXTCALL(glPassTexCoordATI(GL_REG_0_ATI + stage + 1,
|
|
|
|
GL_TEXTURE0_ARB + stage + 1,
|
2008-08-21 20:47:41 +02:00
|
|
|
swizzle));
|
2008-03-20 18:38:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Pass 2: Generate perturbation calculations */
|
2009-10-29 10:37:10 +01:00
|
|
|
for (stage = 0; stage < gl_info->limits.textures; ++stage)
|
2009-10-22 10:09:54 +02:00
|
|
|
{
|
2008-12-03 14:53:43 +01:00
|
|
|
GLuint argmodextra_x, argmodextra_y;
|
|
|
|
struct color_fixup_desc fixup;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
if (op[stage].cop == WINED3D_TOP_DISABLE)
|
|
|
|
break;
|
|
|
|
if (op[stage].cop != WINED3D_TOP_BUMPENVMAP
|
|
|
|
&& op[stage].cop != WINED3D_TOP_BUMPENVMAP_LUMINANCE)
|
|
|
|
continue;
|
2008-03-20 18:38:47 +01:00
|
|
|
|
2008-12-10 10:04:40 +01:00
|
|
|
fixup = op[stage].color_fixup;
|
2008-12-03 14:53:43 +01:00
|
|
|
if (fixup.x_source != CHANNEL_SOURCE_X || fixup.y_source != CHANNEL_SOURCE_Y)
|
|
|
|
{
|
|
|
|
FIXME("Swizzles not implemented\n");
|
|
|
|
argmodextra_x = GL_NONE;
|
|
|
|
argmodextra_y = GL_NONE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Nice thing, we get the color correction for free :-) */
|
|
|
|
argmodextra_x = fixup.x_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
|
|
|
|
argmodextra_y = fixup.y_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
|
2008-03-20 18:38:47 +01:00
|
|
|
}
|
|
|
|
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_RED_BIT_ATI, GL_NONE,
|
|
|
|
GL_REG_0_ATI + stage, GL_NONE, argmodextra_x,
|
2015-03-26 19:02:41 +01:00
|
|
|
ATIFS_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
|
2008-12-09 18:16:14 +01:00
|
|
|
GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE);
|
2008-03-20 18:38:47 +01:00
|
|
|
|
2009-05-29 23:01:07 +02:00
|
|
|
/* Don't use GL_DOT2_ADD_ATI here because we cannot configure it to read the blue and alpha
|
|
|
|
* component of the bump matrix. Instead do this with two MADs:
|
|
|
|
*
|
|
|
|
* coord.a = tex.r * bump.b + coord.g
|
|
|
|
* coord.g = tex.g * bump.a + coord.a
|
2008-03-20 18:38:47 +01:00
|
|
|
*
|
2009-05-29 23:01:07 +02:00
|
|
|
* The first instruction writes to alpha so it can be coissued with the above DOT2_ADD.
|
|
|
|
* coord.a is unused. If the perturbed texture is projected, this was already handled
|
|
|
|
* in the glPassTexCoordATI above.
|
2008-03-20 18:38:47 +01:00
|
|
|
*/
|
2009-05-29 23:01:07 +02:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, GL_REG_0_ATI + stage + 1, GL_ALPHA, GL_NONE,
|
|
|
|
GL_REG_0_ATI + stage, GL_RED, argmodextra_y,
|
2015-03-26 19:02:41 +01:00
|
|
|
ATIFS_CONST_BUMPMAT(stage), GL_BLUE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
|
2008-12-09 18:16:14 +01:00
|
|
|
GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE);
|
2009-05-29 23:01:07 +02:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
|
|
|
|
GL_REG_0_ATI + stage, GL_GREEN, argmodextra_y,
|
2015-03-26 19:02:41 +01:00
|
|
|
ATIFS_CONST_BUMPMAT(stage), GL_ALPHA, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
|
2009-05-29 23:01:07 +02:00
|
|
|
GL_REG_0_ATI + stage + 1, GL_ALPHA, GL_NONE);
|
2008-03-20 18:38:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Pass 3: Generate sampling instructions for regular textures */
|
2009-10-29 10:37:10 +01:00
|
|
|
for (stage = 0; stage < gl_info->limits.textures; ++stage)
|
2009-10-22 10:09:54 +02:00
|
|
|
{
|
2012-01-10 20:37:01 +01:00
|
|
|
if (op[stage].cop == WINED3D_TOP_DISABLE)
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2018-03-23 11:44:30 +01:00
|
|
|
if (op[stage].projected == WINED3D_PROJECTION_NONE)
|
2008-03-22 14:31:52 +01:00
|
|
|
swizzle = GL_SWIZZLE_STR_ATI;
|
2018-03-23 11:44:30 +01:00
|
|
|
else if (op[stage].projected == WINED3D_PROJECTION_COUNT3)
|
2008-08-23 22:41:51 +02:00
|
|
|
swizzle = GL_SWIZZLE_STR_DR_ATI;
|
2018-03-23 11:44:30 +01:00
|
|
|
else
|
2008-03-22 14:31:52 +01:00
|
|
|
swizzle = GL_SWIZZLE_STQ_DQ_ATI;
|
|
|
|
|
2015-03-23 18:59:07 +01:00
|
|
|
if (op_reads_texture(&op[stage]))
|
2012-01-10 20:37:01 +01:00
|
|
|
{
|
|
|
|
if (stage > 0
|
|
|
|
&& (op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP
|
|
|
|
|| op[stage - 1].cop == WINED3D_TOP_BUMPENVMAP_LUMINANCE))
|
|
|
|
{
|
2008-03-20 18:38:47 +01:00
|
|
|
TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_REG_%d_ATI, GL_SWIZZLE_STR_ATI)\n",
|
|
|
|
stage, stage);
|
|
|
|
GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI + stage,
|
|
|
|
GL_REG_0_ATI + stage,
|
|
|
|
GL_SWIZZLE_STR_ATI));
|
|
|
|
} else {
|
|
|
|
TRACE("glSampleMapATI(GL_REG_%d_ATI, GL_TEXTURE_%d_ARB, %s)\n",
|
|
|
|
stage, stage, debug_swizzle(swizzle));
|
|
|
|
GL_EXTCALL(glSampleMapATI(GL_REG_0_ATI + stage,
|
|
|
|
GL_TEXTURE0_ARB + stage,
|
|
|
|
swizzle));
|
|
|
|
}
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-20 18:38:47 +01:00
|
|
|
/* Pass 4: Generate the arithmetic instructions */
|
2019-02-20 21:53:57 +01:00
|
|
|
for (stage = 0; stage < WINED3D_MAX_TEXTURES; ++stage)
|
2010-09-14 13:38:39 +02:00
|
|
|
{
|
2012-01-10 20:37:01 +01:00
|
|
|
if (op[stage].cop == WINED3D_TOP_DISABLE)
|
2010-09-14 13:38:39 +02:00
|
|
|
{
|
|
|
|
if (!stage)
|
|
|
|
{
|
2008-03-22 14:31:52 +01:00
|
|
|
/* Handle complete texture disabling gracefully */
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_NONE, GL_NONE,
|
|
|
|
GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
|
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE,
|
|
|
|
GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2018-03-23 11:44:31 +01:00
|
|
|
if (op[stage].tmp_dst)
|
|
|
|
{
|
|
|
|
/* If we're writing to D3DTA_TEMP, but never reading from it we
|
|
|
|
* don't have to write there in the first place. Skip the entire
|
|
|
|
* stage, this saves some GPU time. */
|
|
|
|
if (tmparg == GL_NONE)
|
|
|
|
continue;
|
2008-03-29 23:55:09 +01:00
|
|
|
|
|
|
|
dstreg = tmparg;
|
2018-03-23 11:44:31 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2008-03-29 23:55:09 +01:00
|
|
|
dstreg = GL_REG_0_ATI;
|
|
|
|
}
|
2008-03-29 00:41:07 +01:00
|
|
|
|
2015-03-23 18:59:07 +01:00
|
|
|
if (op[stage].cop == WINED3D_TOP_BUMPENVMAP || op[stage].cop == WINED3D_TOP_BUMPENVMAP_LUMINANCE)
|
|
|
|
{
|
|
|
|
/* Those are handled in the first pass of the shader (generation pass 1 and 2) already */
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-08-19 17:43:03 +02:00
|
|
|
arg0 = register_for_arg(op[stage].carg0, gl_info, stage, &argmod0, &rep0, tmparg);
|
|
|
|
arg1 = register_for_arg(op[stage].carg1, gl_info, stage, &argmod1, &rep1, tmparg);
|
|
|
|
arg2 = register_for_arg(op[stage].carg2, gl_info, stage, &argmod2, &rep2, tmparg);
|
2008-03-22 14:31:52 +01:00
|
|
|
dstmod = GL_NONE;
|
|
|
|
argmodextra = GL_NONE;
|
|
|
|
extrarg = GL_NONE;
|
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
if (op_reads_tfactor(&op[stage]))
|
|
|
|
tfactor_used = TRUE;
|
|
|
|
|
2015-03-26 19:02:41 +01:00
|
|
|
if (op_reads_constant(&op[stage]))
|
|
|
|
{
|
|
|
|
if (constants[stage] != ATIFS_CONSTANT_UNUSED)
|
|
|
|
FIXME("Constant %u already used.\n", stage);
|
|
|
|
constants[stage] = ATIFS_CONSTANT_STAGE;
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:59:07 +01:00
|
|
|
if (op_reads_texture(&op[stage]) && !is_identity_fixup(op[stage].color_fixup))
|
|
|
|
atifs_color_fixup(gl_info, op[stage].color_fixup, GL_REG_0_ATI + stage);
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
switch (op[stage].cop)
|
|
|
|
{
|
|
|
|
case WINED3D_TOP_SELECT_ARG2:
|
2008-03-22 14:31:52 +01:00
|
|
|
arg1 = arg2;
|
|
|
|
argmod1 = argmod2;
|
2008-08-19 17:43:03 +02:00
|
|
|
rep1 = rep2;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_SELECT_ARG1:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, dstreg, GL_NONE, GL_NONE,
|
|
|
|
arg1, rep1, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_4X:
|
2008-03-22 14:31:52 +01:00
|
|
|
if(dstmod == GL_NONE) dstmod = GL_4X_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_2X:
|
2008-03-22 14:31:52 +01:00
|
|
|
if(dstmod == GL_NONE) dstmod = GL_2X_BIT_ATI;
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_MUL_ATI, dstreg, GL_NONE, dstmod,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SIGNED_2X:
|
2008-03-22 14:31:52 +01:00
|
|
|
dstmod = GL_2X_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SIGNED:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = GL_BIAS_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD:
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_ADD_ATI, GL_REG_0_ATI, GL_NONE, dstmod,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmodextra | argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_SUBTRACT:
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_SUB_ATI, dstreg, GL_NONE, dstmod,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SMOOTH:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
|
|
|
|
/* Dst = arg1 + * arg2(1 -arg 1)
|
|
|
|
* = arg2 * (1 - arg1) + arg1
|
|
|
|
*/
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
|
|
|
|
arg2, rep2, argmod2,
|
|
|
|
arg1, rep1, argmodextra,
|
|
|
|
arg1, rep1, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_CURRENT_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_CURRENT, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_FACTOR_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_TFACTOR, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_TEXTURE_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_DIFFUSE_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1);
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
|
|
|
|
extrarg, GL_ALPHA, GL_NONE,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM:
|
2008-08-19 17:43:03 +02:00
|
|
|
arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_NONE,
|
|
|
|
arg2, rep2, argmod2,
|
|
|
|
arg0, GL_ALPHA, GL_COMP_BIT_ATI,
|
|
|
|
arg1, rep1, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* D3DTOP_PREMODULATE ???? */
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR:
|
|
|
|
if (!argmodextra)
|
|
|
|
argmodextra = argmod1;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
|
|
|
|
arg2, rep2, argmod2,
|
|
|
|
arg1, GL_ALPHA, argmodextra,
|
|
|
|
arg1, rep1, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA:
|
|
|
|
if (!argmodextra)
|
|
|
|
argmodextra = argmod1;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
|
|
|
|
arg2, rep2, argmod2,
|
|
|
|
arg1, rep1, argmodextra,
|
|
|
|
arg1, GL_ALPHA, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_DOTPRODUCT3:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_DOT3_ATI, dstreg, GL_NONE, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
|
|
|
|
arg1, rep1, argmod1 | GL_BIAS_BIT_ATI,
|
|
|
|
arg2, rep2, argmod2 | GL_BIAS_BIT_ATI);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MULTIPLY_ADD:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_NONE, GL_SATURATE_BIT_ATI,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmod2,
|
|
|
|
arg0, rep0, argmod0);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_LERP:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_NONE, GL_NONE,
|
|
|
|
arg0, rep0, argmod0,
|
|
|
|
arg1, rep1, argmod1,
|
|
|
|
arg2, rep2, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
default: FIXME("Unhandled color operation %d on stage %d\n", op[stage].cop, stage);
|
|
|
|
}
|
|
|
|
|
2008-08-19 17:43:03 +02:00
|
|
|
arg0 = register_for_arg(op[stage].aarg0, gl_info, stage, &argmod0, NULL, tmparg);
|
|
|
|
arg1 = register_for_arg(op[stage].aarg1, gl_info, stage, &argmod1, NULL, tmparg);
|
|
|
|
arg2 = register_for_arg(op[stage].aarg2, gl_info, stage, &argmod2, NULL, tmparg);
|
2008-03-22 14:31:52 +01:00
|
|
|
dstmod = GL_NONE;
|
|
|
|
argmodextra = GL_NONE;
|
|
|
|
extrarg = GL_NONE;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
switch (op[stage].aop)
|
|
|
|
{
|
|
|
|
case WINED3D_TOP_DISABLE:
|
2008-03-22 14:31:52 +01:00
|
|
|
/* Get the primary color to the output if on stage 0, otherwise leave register 0 untouched */
|
2010-09-14 13:38:39 +02:00
|
|
|
if (!stage)
|
|
|
|
{
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, GL_REG_0_ATI, GL_ALPHA, GL_NONE,
|
|
|
|
GL_PRIMARY_COLOR, GL_NONE, GL_NONE);
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_SELECT_ARG2:
|
2008-03-22 14:31:52 +01:00
|
|
|
arg1 = arg2;
|
|
|
|
argmod1 = argmod2;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_SELECT_ARG1:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op1(gl_info, GL_MOV_ATI, dstreg, GL_ALPHA, GL_NONE,
|
|
|
|
arg1, GL_NONE, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_4X:
|
|
|
|
if (dstmod == GL_NONE)
|
|
|
|
dstmod = GL_4X_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_2X:
|
|
|
|
if (dstmod == GL_NONE)
|
|
|
|
dstmod = GL_2X_BIT_ATI;
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_MUL_ATI, dstreg, GL_ALPHA, dstmod,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SIGNED_2X:
|
2008-03-22 14:31:52 +01:00
|
|
|
dstmod = GL_2X_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SIGNED:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = GL_BIAS_BIT_ATI;
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD:
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_ADD_ATI, dstreg, GL_ALPHA, dstmod,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmodextra | argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_SUBTRACT:
|
2008-08-14 23:29:47 +02:00
|
|
|
dstmod |= GL_SATURATE_BIT_ATI;
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_SUB_ATI, dstreg, GL_ALPHA, dstmod,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_ADD_SMOOTH:
|
2008-03-22 14:31:52 +01:00
|
|
|
argmodextra = argmod1 & GL_COMP_BIT_ATI ? argmod1 & ~GL_COMP_BIT_ATI : argmod1 | GL_COMP_BIT_ATI;
|
|
|
|
/* Dst = arg1 + * arg2(1 -arg 1)
|
|
|
|
* = arg2 * (1 - arg1) + arg1
|
|
|
|
*/
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
|
|
|
|
arg2, GL_NONE, argmod2,
|
|
|
|
arg1, GL_NONE, argmodextra,
|
|
|
|
arg1, GL_NONE, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_CURRENT_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_CURRENT, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_FACTOR_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_TFACTOR, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_TEXTURE_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
|
2011-10-13 23:17:55 +02:00
|
|
|
/* fall through */
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_DIFFUSE_ALPHA:
|
|
|
|
if (extrarg == GL_NONE)
|
|
|
|
extrarg = register_for_arg(WINED3DTA_DIFFUSE, gl_info, stage, NULL, NULL, -1);
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_ALPHA, GL_NONE,
|
|
|
|
extrarg, GL_ALPHA, GL_NONE,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmod2);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_BLEND_TEXTURE_ALPHA_PM:
|
2008-08-19 17:43:03 +02:00
|
|
|
arg0 = register_for_arg(WINED3DTA_TEXTURE, gl_info, stage, NULL, NULL, -1);
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_NONE,
|
|
|
|
arg2, GL_NONE, argmod2,
|
|
|
|
arg0, GL_ALPHA, GL_COMP_BIT_ATI,
|
|
|
|
arg1, GL_NONE, argmod1);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* D3DTOP_PREMODULATE ???? */
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_DOTPRODUCT3:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op2(gl_info, GL_DOT3_ATI, dstreg, GL_ALPHA, GL_4X_BIT_ATI | GL_SATURATE_BIT_ATI,
|
|
|
|
arg1, GL_NONE, argmod1 | GL_BIAS_BIT_ATI,
|
|
|
|
arg2, GL_NONE, argmod2 | GL_BIAS_BIT_ATI);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MULTIPLY_ADD:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_MAD_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmod2,
|
|
|
|
arg0, GL_NONE, argmod0);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_LERP:
|
2008-12-09 18:16:14 +01:00
|
|
|
wrap_op3(gl_info, GL_LERP_ATI, dstreg, GL_ALPHA, GL_SATURATE_BIT_ATI,
|
|
|
|
arg1, GL_NONE, argmod1,
|
|
|
|
arg2, GL_NONE, argmod2,
|
|
|
|
arg0, GL_NONE, argmod0);
|
2008-03-22 14:31:52 +01:00
|
|
|
break;
|
|
|
|
|
2012-01-10 20:37:01 +01:00
|
|
|
case WINED3D_TOP_MODULATE_INVALPHA_ADD_COLOR:
|
|
|
|
case WINED3D_TOP_MODULATE_ALPHA_ADD_COLOR:
|
|
|
|
case WINED3D_TOP_MODULATE_COLOR_ADD_ALPHA:
|
|
|
|
case WINED3D_TOP_MODULATE_INVCOLOR_ADD_ALPHA:
|
|
|
|
case WINED3D_TOP_BUMPENVMAP:
|
|
|
|
case WINED3D_TOP_BUMPENVMAP_LUMINANCE:
|
2008-03-22 14:31:52 +01:00
|
|
|
ERR("Application uses an invalid alpha operation\n");
|
|
|
|
break;
|
|
|
|
|
|
|
|
default: FIXME("Unhandled alpha operation %d on stage %d\n", op[stage].aop, stage);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-03-26 19:02:41 +01:00
|
|
|
if (tfactor_used && constants[ATIFS_CONST_TFACTOR - GL_CON_0_ATI] != ATIFS_CONSTANT_UNUSED)
|
2015-03-23 18:59:10 +01:00
|
|
|
FIXME("Texture factor constant already used.\n");
|
2015-03-26 19:02:41 +01:00
|
|
|
constants[ATIFS_CONST_TFACTOR - GL_CON_0_ATI] = ATIFS_CONSTANT_TFACTOR;
|
2015-03-23 18:59:10 +01:00
|
|
|
|
|
|
|
/* Assign unused constants to avoid reloading due to unused <-> bump matrix switches. */
|
2019-02-20 21:53:57 +01:00
|
|
|
for (stage = 0; stage < WINED3D_MAX_TEXTURES; ++stage)
|
2015-03-23 18:59:10 +01:00
|
|
|
{
|
|
|
|
if (constants[stage] == ATIFS_CONSTANT_UNUSED)
|
|
|
|
constants[stage] = ATIFS_CONSTANT_BUMP;
|
|
|
|
}
|
|
|
|
|
2008-03-22 14:31:52 +01:00
|
|
|
TRACE("glEndFragmentShaderATI()\n");
|
|
|
|
GL_EXTCALL(glEndFragmentShaderATI());
|
|
|
|
checkGLcall("GL_EXTCALL(glEndFragmentShaderATI())");
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
static void atifs_tfactor(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
|
|
|
{
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
|
2016-03-08 15:51:13 +01:00
|
|
|
struct wined3d_color color;
|
2015-03-23 18:59:10 +01:00
|
|
|
|
|
|
|
if (!ctx_priv->last_shader
|
2015-03-26 19:02:41 +01:00
|
|
|
|| ctx_priv->last_shader->constants[ATIFS_CONST_TFACTOR - GL_CON_0_ATI] != ATIFS_CONSTANT_TFACTOR)
|
2015-03-23 18:59:10 +01:00
|
|
|
return;
|
|
|
|
|
2016-03-08 15:51:13 +01:00
|
|
|
wined3d_color_from_d3dcolor(&color, state->render_states[WINED3D_RS_TEXTUREFACTOR]);
|
|
|
|
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, &color.r));
|
|
|
|
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_TFACTOR, &color.r)");
|
2015-03-23 18:59:10 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static void set_bumpmat(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
|
|
|
{
|
|
|
|
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
float mat[2][2];
|
|
|
|
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
|
|
|
|
|
|
|
|
if (!ctx_priv->last_shader
|
|
|
|
|| ctx_priv->last_shader->constants[stage] != ATIFS_CONSTANT_BUMP)
|
|
|
|
return;
|
|
|
|
|
|
|
|
mat[0][0] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT00]);
|
|
|
|
mat[1][0] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT01]);
|
|
|
|
mat[0][1] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT10]);
|
|
|
|
mat[1][1] = *((float *)&state->texture_states[stage][WINED3D_TSS_BUMPENV_MAT11]);
|
|
|
|
/* GL_ATI_fragment_shader allows only constants from 0.0 to 1.0, but the bumpmat
|
|
|
|
* constants can be in any range. While they should stay between [-1.0 and 1.0] because
|
|
|
|
* Shader Model 1.x pixel shaders are clamped to that range negative values are used occasionally,
|
|
|
|
* for example by our d3d9 test. So to get negative values scale -1;1 to 0;1 and undo that in the
|
|
|
|
* shader(it is free). This might potentially reduce precision. However, if the hardware does
|
|
|
|
* support proper floats it shouldn't, and if it doesn't we can't get anything better anyway. */
|
|
|
|
mat[0][0] = (mat[0][0] + 1.0f) * 0.5f;
|
|
|
|
mat[1][0] = (mat[1][0] + 1.0f) * 0.5f;
|
|
|
|
mat[0][1] = (mat[0][1] + 1.0f) * 0.5f;
|
|
|
|
mat[1][1] = (mat[1][1] + 1.0f) * 0.5f;
|
2015-03-26 19:02:41 +01:00
|
|
|
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_BUMPMAT(stage), (float *) mat));
|
|
|
|
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_BUMPMAT(stage), mat)");
|
|
|
|
}
|
|
|
|
|
|
|
|
static void atifs_stage_constant(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
|
|
|
{
|
|
|
|
DWORD stage = (state_id - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1);
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
|
2016-03-08 15:51:13 +01:00
|
|
|
struct wined3d_color color;
|
2015-03-26 19:02:41 +01:00
|
|
|
|
|
|
|
if (!ctx_priv->last_shader
|
|
|
|
|| ctx_priv->last_shader->constants[stage] != ATIFS_CONSTANT_STAGE)
|
|
|
|
return;
|
|
|
|
|
2016-03-08 15:51:13 +01:00
|
|
|
wined3d_color_from_d3dcolor(&color, state->texture_states[stage][WINED3D_TSS_CONSTANT]);
|
|
|
|
GL_EXTCALL(glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), &color.r));
|
|
|
|
checkGLcall("glSetFragmentShaderConstantATI(ATIFS_CONST_STAGE(stage), &color.r)");
|
2015-03-23 18:59:10 +01:00
|
|
|
}
|
|
|
|
|
2011-07-14 01:02:48 +02:00
|
|
|
static void set_tex_op_atifs(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
2009-08-03 08:06:51 +02:00
|
|
|
{
|
2015-03-23 18:59:10 +01:00
|
|
|
struct atifs_context_private_data *ctx_priv = context->fragment_pipe_data;
|
|
|
|
const struct atifs_ffp_desc *desc, *last_shader = ctx_priv->last_shader;
|
2019-05-10 18:31:05 +02:00
|
|
|
struct wined3d_context_gl *context_gl = wined3d_context_gl(context);
|
|
|
|
const struct wined3d_d3d_info *d3d_info = context->d3d_info;
|
|
|
|
const struct wined3d_gl_info *gl_info = context->gl_info;
|
|
|
|
const struct wined3d_device *device = context->device;
|
2011-05-16 23:01:23 +02:00
|
|
|
struct atifs_private_data *priv = device->fragment_priv;
|
2019-05-10 18:31:05 +02:00
|
|
|
struct ffp_frag_settings settings;
|
2008-04-23 22:23:57 +02:00
|
|
|
DWORD mapped_stage;
|
|
|
|
unsigned int i;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2013-04-25 15:20:26 +02:00
|
|
|
gen_ffp_frag_op(context, state, &settings, TRUE);
|
2009-06-03 10:47:26 +02:00
|
|
|
desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(&priv->fragment_shaders, &settings);
|
2017-03-13 11:57:19 +01:00
|
|
|
if (!desc)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct atifs_ffp_desc *new_desc;
|
|
|
|
|
|
|
|
if (!(new_desc = heap_alloc_zero(sizeof(*new_desc))))
|
2008-11-25 14:36:08 +01:00
|
|
|
{
|
2008-03-22 14:31:52 +01:00
|
|
|
ERR("Out of memory\n");
|
|
|
|
return;
|
|
|
|
}
|
2008-11-25 14:36:08 +01:00
|
|
|
new_desc->num_textures_used = 0;
|
2013-04-25 15:20:30 +02:00
|
|
|
for (i = 0; i < d3d_info->limits.ffp_blend_stages; ++i)
|
2009-10-22 10:09:54 +02:00
|
|
|
{
|
2012-01-10 20:37:01 +01:00
|
|
|
if (settings.op[i].cop == WINED3D_TOP_DISABLE)
|
|
|
|
break;
|
2017-03-13 11:57:19 +01:00
|
|
|
++new_desc->num_textures_used;
|
2008-04-23 22:23:57 +02:00
|
|
|
}
|
|
|
|
|
2013-01-27 22:57:20 +01:00
|
|
|
new_desc->parent.settings = settings;
|
2015-03-23 18:59:10 +01:00
|
|
|
new_desc->shader = gen_ati_shader(settings.op, gl_info, new_desc->constants);
|
2009-06-03 10:47:26 +02:00
|
|
|
add_ffp_frag_shader(&priv->fragment_shaders, &new_desc->parent);
|
2017-03-13 11:57:19 +01:00
|
|
|
TRACE("Allocated fixed function replacement shader descriptor %p.\n", new_desc);
|
2008-11-25 14:36:08 +01:00
|
|
|
desc = new_desc;
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
|
2008-04-23 22:23:57 +02:00
|
|
|
/* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
|
|
|
|
* used by this shader
|
|
|
|
*/
|
2011-05-16 23:01:23 +02:00
|
|
|
for (i = 0; i < desc->num_textures_used; ++i)
|
|
|
|
{
|
2019-05-10 18:31:05 +02:00
|
|
|
mapped_stage = context_gl->tex_unit_map[i];
|
2009-03-09 14:31:28 +01:00
|
|
|
if (mapped_stage != WINED3D_UNMAPPED_STAGE)
|
|
|
|
{
|
2019-06-05 14:24:04 +02:00
|
|
|
wined3d_context_gl_active_texture(context_gl, gl_info, mapped_stage);
|
2011-07-14 01:02:48 +02:00
|
|
|
texture_activate_dimensions(state->textures[i], gl_info);
|
2008-04-23 22:23:57 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-03-22 14:31:52 +01:00
|
|
|
GL_EXTCALL(glBindFragmentShaderATI(desc->shader));
|
2015-03-23 18:59:10 +01:00
|
|
|
ctx_priv->last_shader = desc;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2019-02-20 21:53:57 +01:00
|
|
|
for (i = 0; i < WINED3D_MAX_TEXTURES; i++)
|
2015-03-23 18:59:10 +01:00
|
|
|
{
|
|
|
|
if (last_shader && last_shader->constants[i] == desc->constants[i])
|
|
|
|
continue;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
switch (desc->constants[i])
|
|
|
|
{
|
|
|
|
case ATIFS_CONSTANT_BUMP:
|
|
|
|
set_bumpmat(context, state, STATE_TEXTURESTAGE(i, WINED3D_TSS_BUMPENV_MAT00));
|
|
|
|
break;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
case ATIFS_CONSTANT_TFACTOR:
|
|
|
|
atifs_tfactor(context, state, STATE_RENDER(WINED3D_RS_TEXTUREFACTOR));
|
|
|
|
break;
|
2008-03-20 18:38:47 +01:00
|
|
|
|
2015-03-26 19:02:41 +01:00
|
|
|
case ATIFS_CONSTANT_STAGE:
|
|
|
|
atifs_stage_constant(context, state, STATE_TEXTURESTAGE(i, WINED3D_TSS_CONSTANT));
|
|
|
|
break;
|
|
|
|
|
2015-03-23 18:59:10 +01:00
|
|
|
default:
|
|
|
|
ERR("Unexpected constant type %u.\n", desc->constants[i]);
|
|
|
|
}
|
|
|
|
}
|
2008-03-20 18:38:47 +01:00
|
|
|
}
|
2008-08-23 22:41:51 +02:00
|
|
|
|
2011-07-14 01:02:48 +02:00
|
|
|
static void textransform(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
2009-08-03 08:06:51 +02:00
|
|
|
{
|
2013-10-09 10:39:38 +02:00
|
|
|
if (!isStateDirty(context, STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL)))
|
2011-07-14 01:02:48 +02:00
|
|
|
set_tex_op_atifs(context, state, state_id);
|
2008-08-23 22:41:51 +02:00
|
|
|
}
|
|
|
|
|
2011-07-14 01:02:48 +02:00
|
|
|
static void atifs_srgbwriteenable(struct wined3d_context *context, const struct wined3d_state *state, DWORD state_id)
|
2010-09-02 19:25:03 +02:00
|
|
|
{
|
2011-12-19 21:00:09 +01:00
|
|
|
if (state->render_states[WINED3D_RS_SRGBWRITEENABLE])
|
2010-09-02 19:25:03 +02:00
|
|
|
WARN("sRGB writes are not supported by this fragment pipe.\n");
|
|
|
|
}
|
|
|
|
|
2019-03-03 19:55:27 +01:00
|
|
|
static const struct wined3d_state_entry_template atifs_fragmentstate_template[] =
|
|
|
|
{
|
2015-03-23 18:59:10 +01:00
|
|
|
{STATE_RENDER(WINED3D_RS_TEXTUREFACTOR), { STATE_RENDER(WINED3D_RS_TEXTUREFACTOR), atifs_tfactor }, WINED3D_GL_EXT_NONE },
|
2015-04-09 22:48:16 +02:00
|
|
|
{STATE_RENDER(WINED3D_RS_ALPHAFUNC), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_ALPHAREF), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), state_alpha_test }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_COLORKEYENABLE), { STATE_RENDER(WINED3D_RS_ALPHATESTENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
2011-12-19 21:00:09 +01:00
|
|
|
{STATE_RENDER(WINED3D_RS_FOGCOLOR), { STATE_RENDER(WINED3D_RS_FOGCOLOR), state_fogcolor }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGDENSITY), { STATE_RENDER(WINED3D_RS_FOGDENSITY), state_fogdensity }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGENABLE), { STATE_RENDER(WINED3D_RS_FOGENABLE), state_fog_fragpart }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGTABLEMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGVERTEXMODE), { STATE_RENDER(WINED3D_RS_FOGENABLE), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGSTART), { STATE_RENDER(WINED3D_RS_FOGSTART), state_fogstartend }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_FOGEND), { STATE_RENDER(WINED3D_RS_FOGSTART), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), { STATE_RENDER(WINED3D_RS_SRGBWRITEENABLE), atifs_srgbwriteenable }, WINED3D_GL_EXT_NONE },
|
2015-04-14 11:16:22 +02:00
|
|
|
{STATE_COLOR_KEY, { STATE_COLOR_KEY, state_nop }, WINED3D_GL_EXT_NONE },
|
2015-11-12 23:06:50 +01:00
|
|
|
{STATE_RENDER(WINED3D_RS_SHADEMODE), { STATE_RENDER(WINED3D_RS_SHADEMODE), state_shademode }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(0, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(0, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(1, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(1, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(2, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(2, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(3, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(3, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(4, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(4, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(5, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(5, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(6, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(6, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_COLOR_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_OP), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG1), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG2), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_ALPHA_ARG0), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_RESULT_ARG), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), NULL }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), set_bumpmat }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT01), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT10), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT11), { STATE_TEXTURESTAGE(7, WINED3D_TSS_BUMPENV_MAT00), NULL }, WINED3D_GL_EXT_NONE },
|
2015-03-26 19:02:41 +01:00
|
|
|
{STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), { STATE_TEXTURESTAGE(7, WINED3D_TSS_CONSTANT), atifs_stage_constant }, WINED3D_GL_EXT_NONE },
|
2009-06-04 10:16:21 +02:00
|
|
|
{ STATE_SAMPLER(0), { STATE_SAMPLER(0), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(1), { STATE_SAMPLER(1), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(2), { STATE_SAMPLER(2), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(3), { STATE_SAMPLER(3), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(4), { STATE_SAMPLER(4), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(5), { STATE_SAMPLER(5), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(6), { STATE_SAMPLER(6), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
|
|
|
{ STATE_SAMPLER(7), { STATE_SAMPLER(7), sampler_texdim }, WINED3D_GL_EXT_NONE },
|
2012-01-09 22:16:51 +01:00
|
|
|
{STATE_TEXTURESTAGE(0,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(0, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(1,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(1, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(2,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(2, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(3,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(3, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(4,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(4, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(5,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(5, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(6,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(6, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
|
|
|
{STATE_TEXTURESTAGE(7,WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), {STATE_TEXTURESTAGE(7, WINED3D_TSS_TEXTURE_TRANSFORM_FLAGS), textransform }, WINED3D_GL_EXT_NONE },
|
2015-03-23 18:59:08 +01:00
|
|
|
{STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), { STATE_SHADER(WINED3D_SHADER_TYPE_PIXEL), set_tex_op_atifs }, WINED3D_GL_EXT_NONE },
|
2009-06-04 10:16:21 +02:00
|
|
|
{0 /* Terminate */, { 0, 0 }, WINED3D_GL_EXT_NONE },
|
2008-07-04 22:01:26 +02:00
|
|
|
};
|
|
|
|
|
2012-12-10 21:54:36 +01:00
|
|
|
/* Context activation is done by the caller. */
|
2012-07-24 11:32:26 +02:00
|
|
|
static void atifs_enable(const struct wined3d_gl_info *gl_info, BOOL enable)
|
2010-12-01 20:50:45 +01:00
|
|
|
{
|
2012-07-24 11:32:27 +02:00
|
|
|
if (enable)
|
|
|
|
{
|
|
|
|
gl_info->gl_ops.gl.p_glEnable(GL_FRAGMENT_SHADER_ATI);
|
2008-07-04 22:09:49 +02:00
|
|
|
checkGLcall("glEnable(GL_FRAGMENT_SHADER_ATI)");
|
2012-07-24 11:32:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
gl_info->gl_ops.gl.p_glDisable(GL_FRAGMENT_SHADER_ATI);
|
2008-07-04 22:09:49 +02:00
|
|
|
checkGLcall("glDisable(GL_FRAGMENT_SHADER_ATI)");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-03-29 13:00:15 +01:00
|
|
|
static void atifs_get_caps(const struct wined3d_adapter *adapter, struct fragment_caps *caps)
|
2008-11-25 14:36:09 +01:00
|
|
|
{
|
2013-01-21 09:08:36 +01:00
|
|
|
caps->wined3d_caps = WINED3D_FRAGMENT_CAP_PROJ_CONTROL;
|
2015-03-26 19:02:41 +01:00
|
|
|
caps->PrimitiveMiscCaps = WINED3DPMISCCAPS_TSSARGTEMP |
|
|
|
|
WINED3DPMISCCAPS_PERSTAGECONSTANT;
|
2008-07-03 21:36:18 +02:00
|
|
|
caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE |
|
|
|
|
WINED3DTEXOPCAPS_SELECTARG1 |
|
|
|
|
WINED3DTEXOPCAPS_SELECTARG2 |
|
|
|
|
WINED3DTEXOPCAPS_MODULATE4X |
|
|
|
|
WINED3DTEXOPCAPS_MODULATE2X |
|
|
|
|
WINED3DTEXOPCAPS_MODULATE |
|
|
|
|
WINED3DTEXOPCAPS_ADDSIGNED2X |
|
|
|
|
WINED3DTEXOPCAPS_ADDSIGNED |
|
|
|
|
WINED3DTEXOPCAPS_ADD |
|
|
|
|
WINED3DTEXOPCAPS_SUBTRACT |
|
|
|
|
WINED3DTEXOPCAPS_ADDSMOOTH |
|
|
|
|
WINED3DTEXOPCAPS_BLENDCURRENTALPHA |
|
|
|
|
WINED3DTEXOPCAPS_BLENDFACTORALPHA |
|
|
|
|
WINED3DTEXOPCAPS_BLENDTEXTUREALPHA |
|
|
|
|
WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA |
|
|
|
|
WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM |
|
|
|
|
WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
|
|
|
|
WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
|
|
|
|
WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA |
|
|
|
|
WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR |
|
|
|
|
WINED3DTEXOPCAPS_DOTPRODUCT3 |
|
|
|
|
WINED3DTEXOPCAPS_MULTIPLYADD |
|
|
|
|
WINED3DTEXOPCAPS_LERP |
|
|
|
|
WINED3DTEXOPCAPS_BUMPENVMAP;
|
|
|
|
|
|
|
|
/* TODO: Implement WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
|
|
|
|
and WINED3DTEXOPCAPS_PREMODULATE */
|
|
|
|
|
|
|
|
/* GL_ATI_fragment_shader always supports 6 textures, which was the limit on r200 cards
|
|
|
|
* which this extension is exclusively focused on(later cards have GL_ARB_fragment_program).
|
|
|
|
* If the current card has more than 8 fixed function textures in OpenGL's regular fixed
|
|
|
|
* function pipeline then the ATI_fragment_shader backend imposes a stricter limit. This
|
|
|
|
* shouldn't be too hard since Nvidia cards have a limit of 4 textures with the default ffp
|
|
|
|
* pipeline, and almost all games are happy with that. We can however support up to 8
|
|
|
|
* texture stages because we have a 2nd pass limit of 8 instructions, and per stage we use
|
|
|
|
* only 1 instruction.
|
|
|
|
*
|
|
|
|
* The proper fix for this is not to use GL_ATI_fragment_shader on cards newer than the
|
|
|
|
* r200 series and use an ARB or GLSL shader instead
|
|
|
|
*/
|
2019-02-20 21:53:57 +01:00
|
|
|
caps->MaxTextureBlendStages = WINED3D_MAX_TEXTURES;
|
2008-07-03 21:36:18 +02:00
|
|
|
caps->MaxSimultaneousTextures = 6;
|
|
|
|
}
|
|
|
|
|
2015-07-27 14:29:57 +02:00
|
|
|
static DWORD atifs_get_emul_mask(const struct wined3d_gl_info *gl_info)
|
|
|
|
{
|
|
|
|
return GL_EXT_EMUL_ARB_MULTITEXTURE | GL_EXT_EMUL_EXT_FOG_COORD;
|
|
|
|
}
|
|
|
|
|
2012-10-28 20:54:54 +01:00
|
|
|
static void *atifs_alloc(const struct wined3d_shader_backend_ops *shader_backend, void *shader_priv)
|
2010-12-01 20:50:46 +01:00
|
|
|
{
|
2008-03-22 14:31:52 +01:00
|
|
|
struct atifs_private_data *priv;
|
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
if (!(priv = heap_alloc_zero(sizeof(*priv))))
|
2012-10-28 20:54:54 +01:00
|
|
|
return NULL;
|
2013-02-05 15:49:14 +01:00
|
|
|
|
2016-09-01 10:55:49 +02:00
|
|
|
wine_rb_init(&priv->fragment_shaders, wined3d_ffp_frag_program_key_compare);
|
2012-10-28 20:54:54 +01:00
|
|
|
return priv;
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
|
2009-06-26 10:07:12 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2019-03-26 18:29:46 +01:00
|
|
|
static void atifs_free_ffpshader(struct wine_rb_entry *entry, void *param)
|
2009-06-03 10:47:26 +02:00
|
|
|
{
|
|
|
|
struct atifs_ffp_desc *entry_ati = WINE_RB_ENTRY_VALUE(entry, struct atifs_ffp_desc, parent.entry);
|
2019-03-26 18:29:46 +01:00
|
|
|
struct wined3d_context *context = param;
|
|
|
|
const struct wined3d_gl_info *gl_info;
|
2008-07-29 17:51:52 +02:00
|
|
|
|
2019-03-26 18:29:46 +01:00
|
|
|
gl_info = context->gl_info;
|
2008-07-29 17:51:52 +02:00
|
|
|
GL_EXTCALL(glDeleteFragmentShaderATI(entry_ati->shader));
|
|
|
|
checkGLcall("glDeleteFragmentShaderATI(entry->shader)");
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(entry_ati);
|
2008-07-29 17:51:52 +02:00
|
|
|
}
|
|
|
|
|
2009-06-26 10:07:12 +02:00
|
|
|
/* Context activation is done by the caller. */
|
2019-03-26 18:29:46 +01:00
|
|
|
static void atifs_free(struct wined3d_device *device, struct wined3d_context *context)
|
2010-12-01 20:50:47 +01:00
|
|
|
{
|
|
|
|
struct atifs_private_data *priv = device->fragment_priv;
|
2008-03-22 14:31:52 +01:00
|
|
|
|
2019-03-26 18:29:46 +01:00
|
|
|
wine_rb_destroy(&priv->fragment_shaders, atifs_free_ffpshader, context);
|
2008-07-29 17:51:52 +02:00
|
|
|
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(priv);
|
2010-12-01 20:50:47 +01:00
|
|
|
device->fragment_priv = NULL;
|
2008-03-22 14:31:52 +01:00
|
|
|
}
|
|
|
|
|
2008-12-03 14:53:43 +01:00
|
|
|
static BOOL atifs_color_fixup_supported(struct color_fixup_desc fixup)
|
|
|
|
{
|
|
|
|
/* We only support sign fixup of the first two channels. */
|
2017-05-26 10:48:04 +02:00
|
|
|
return is_identity_fixup(fixup) || is_same_fixup(fixup, color_fixup_rg)
|
|
|
|
|| is_same_fixup(fixup, color_fixup_rgl) || is_same_fixup(fixup, color_fixup_rgba);
|
2008-08-07 21:51:35 +02:00
|
|
|
}
|
|
|
|
|
2015-03-23 18:59:09 +01:00
|
|
|
static BOOL atifs_alloc_context_data(struct wined3d_context *context)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
struct atifs_context_private_data *priv;
|
|
|
|
|
|
|
|
if (!(priv = heap_alloc_zero(sizeof(*priv))))
|
2015-03-23 18:59:10 +01:00
|
|
|
return FALSE;
|
|
|
|
context->fragment_pipe_data = priv;
|
2015-03-23 18:59:09 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void atifs_free_context_data(struct wined3d_context *context)
|
|
|
|
{
|
2018-02-14 07:39:59 +01:00
|
|
|
heap_free(context->fragment_pipe_data);
|
2015-03-23 18:59:09 +01:00
|
|
|
}
|
|
|
|
|
2008-07-11 16:41:28 +02:00
|
|
|
const struct fragment_pipeline atifs_fragment_pipeline = {
|
|
|
|
atifs_enable,
|
|
|
|
atifs_get_caps,
|
2015-07-27 14:29:57 +02:00
|
|
|
atifs_get_emul_mask,
|
2008-07-11 16:41:28 +02:00
|
|
|
atifs_alloc,
|
|
|
|
atifs_free,
|
2015-03-23 18:59:09 +01:00
|
|
|
atifs_alloc_context_data,
|
|
|
|
atifs_free_context_data,
|
2008-12-03 14:53:43 +01:00
|
|
|
atifs_color_fixup_supported,
|
2008-08-23 22:41:51 +02:00
|
|
|
atifs_fragmentstate_template,
|
2008-03-22 14:31:52 +01:00
|
|
|
};
|