Commit 9f4f02b5 authored by H. Verbeet's avatar H. Verbeet Committed by Alexandre Julliard

wined3d: Split shader_glsl_add_param() in shader_glsl_add_src_param() and…

wined3d: Split shader_glsl_add_param() in shader_glsl_add_src_param() and shader_glsl_add_dst_param().
parent aa4d88d6
......@@ -2,7 +2,7 @@
* GLSL pixel and vertex shader implementation
*
* Copyright 2006 Jason Green
* Copyright 2006 Henri Verbeet
* Copyright 2006-2007 Henri Verbeet
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -479,14 +479,8 @@ void shader_generate_glsl_declarations(
****************************************************************************/
/* Prototypes */
static void shader_glsl_add_param(
SHADER_OPCODE_ARG* arg,
const DWORD param,
const DWORD addr_token,
BOOL is_input,
char *reg_name,
char *reg_mask,
char *out_str);
static void shader_glsl_add_src_param(SHADER_OPCODE_ARG* arg, const DWORD param,
const DWORD addr_token, char *reg_name, char *swizzle, char *out_str);
/** Used for opcode modifiers - They multiply the result by the specified amount */
static const char * const shift_glsl_tab[] = {
......@@ -649,7 +643,7 @@ static void shader_glsl_get_register_name(
* prior to that, it was hard-coded as "A0.x" because there's only 1 register */
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2) {
char relStr[100], relReg[50], relMask[6];
shader_glsl_add_param(arg, addr_token, 0, TRUE, relReg, relMask, relStr);
shader_glsl_add_src_param(arg, addr_token, 0, relReg, relMask, relStr);
sprintf(tmpStr, "%s[%s + %u]", prefix, relStr, reg);
} else
sprintf(tmpStr, "%s[A0.x + %u]", prefix, reg);
......@@ -772,30 +766,32 @@ static void shader_glsl_get_swizzle(const DWORD param, BOOL fixup, char *swizzle
*ptr = '\0';
}
/** From a given parameter token, generate the corresponding GLSL string.
/* From a given parameter token, generate the corresponding GLSL string.
* Also, return the actual register name and swizzle in case the
* caller needs this information as well. */
static void shader_glsl_add_param(
SHADER_OPCODE_ARG* arg,
const DWORD param,
const DWORD addr_token,
BOOL is_input,
char *reg_name,
char *reg_mask,
char *out_str) {
static void shader_glsl_add_src_param(SHADER_OPCODE_ARG* arg, const DWORD param,
const DWORD addr_token, char *reg_name, char *swizzle, char *out_str) {
BOOL is_color = FALSE;
swizzle[0] = reg_name[0] = out_str[0] = 0;
shader_glsl_get_register_name(param, addr_token, reg_name, &is_color, arg);
shader_glsl_get_swizzle(param, is_color, swizzle);
shader_glsl_gen_modifier(param, reg_name, swizzle, out_str);
}
/* From a given parameter token, generate the corresponding GLSL string.
* Also, return the actual register name and swizzle in case the
* caller needs this information as well. */
static void shader_glsl_add_dst_param(SHADER_OPCODE_ARG* arg, const DWORD param,
const DWORD addr_token, char *reg_name, char *write_mask, char *out_str) {
BOOL is_color = FALSE;
reg_mask[0] = reg_name[0] = out_str[0] = 0;
write_mask[0] = reg_name[0] = out_str[0] = 0;
shader_glsl_get_register_name(param, addr_token, reg_name, &is_color, arg);
if (is_input) {
shader_glsl_get_swizzle(param, is_color, reg_mask);
shader_glsl_gen_modifier(param, reg_name, reg_mask, out_str);
} else {
shader_glsl_get_write_mask(param, reg_mask);
sprintf(out_str, "%s%s", reg_name, reg_mask);
}
shader_glsl_get_write_mask(param, write_mask);
sprintf(out_str, "%s%s", reg_name, write_mask);
}
/** Process GLSL instruction modifiers */
......@@ -808,7 +804,7 @@ void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG* arg) {
char dst_mask[6];
char dst_str[100];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
if (mask & WINED3DSPDM_SATURATE) {
/* _SAT means to clamp the value of the register to between 0 and 1 */
......@@ -897,9 +893,9 @@ void shader_glsl_arith(SHADER_OPCODE_ARG* arg) {
char dst_mask[6], src0_mask[6], src1_mask[6];
char dst_str[100], src0_str[100], src1_str[100];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
strcat(tmpLine, "vec4(");
strcat(tmpLine, src0_str);
......@@ -926,8 +922,8 @@ void shader_glsl_mov(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50];
char dst_mask[6], src0_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(buffer, "%s%s)%s;\n", tmpLine, src0_str, dst_mask);
}
......@@ -943,9 +939,9 @@ void shader_glsl_dot(SHADER_OPCODE_ARG* arg) {
char dst_mask[6], src0_mask[6], src1_mask[6];
char cast[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpDest);
......@@ -970,7 +966,7 @@ void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
char dst_mask[6], src_mask[6];
unsigned i;
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
......@@ -1000,12 +996,12 @@ void shader_glsl_map2gl(SHADER_OPCODE_ARG* arg) {
if (curOpcode->num_params > 0) {
strcat(tmpLine, "vec4(");
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src_reg, src_mask, src_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src_reg, src_mask, src_str);
strcat(tmpLine, src_str);
strcat(tmpLine, ")");
for (i = 2; i < curOpcode->num_params; ++i) {
strcat(tmpLine, ", vec4(");
shader_glsl_add_param(arg, arg->src[i-1], arg->src_addr[i-1], TRUE, src_reg, src_mask, src_str);
shader_glsl_add_src_param(arg, arg->src[i-1], arg->src_addr[i-1], src_reg, src_mask, src_str);
strcat(tmpLine, src_str);
strcat(tmpLine, ")");
}
......@@ -1032,8 +1028,8 @@ void shader_glsl_expp(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
DWORD hex_version = This->baseShader.hex_version;
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src_reg, src_mask, src_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src_reg, src_mask, src_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
if (hex_version < WINED3DPS_VERSION(2,0)) {
......@@ -1055,8 +1051,8 @@ void shader_glsl_rcp(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src_reg[50];
char dst_mask[6], src_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src_reg, src_mask, src_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src_reg, src_mask, src_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
strcat(tmpLine, "1.0 / ");
shader_addline(arg->buffer, "%s%s)%s;\n", tmpLine, src_str, dst_mask);
......@@ -1070,8 +1066,8 @@ void shader_glsl_compare(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
/* If we are comparing vectors and not scalars, we should process this through map2gl using the GLSL functions. */
......@@ -1080,7 +1076,7 @@ void shader_glsl_compare(SHADER_OPCODE_ARG* arg) {
} else {
char compareStr[3];
compareStr[0] = 0;
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
switch (arg->opcode->opcode) {
case WINED3DSIO_SLT: strcpy(compareStr, "<"); break;
......@@ -1101,10 +1097,10 @@ void shader_glsl_cmp(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%smix(vec4(%s), vec4(%s), vec4(lessThan(vec4(%s), vec4(0.0)))))%s;\n",
......@@ -1119,10 +1115,10 @@ void shader_glsl_cnd(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%s(%s < 0.5) ? %s : %s)%s;\n",
tmpLine, src0_str, src1_str, src2_str, dst_mask);
......@@ -1136,10 +1132,10 @@ void shader_glsl_mad(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%s(vec4(%s) * vec4(%s)) + vec4(%s))%s;\n",
......@@ -1207,10 +1203,10 @@ void shader_glsl_lrp(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
......@@ -1230,8 +1226,8 @@ void shader_glsl_lit(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50];
char dst_mask[6], src0_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_addline(arg->buffer,
"%s = vec4(1.0, (%s.x > 0.0 ? %s.x : 0.0), (%s.x > 0.0 ? ((%s.y > 0.0) ? pow(%s.y, clamp(%s.w, -128.0, 128.0)) : 0.0) : 0.0), 1.0)%s;\n",
......@@ -1250,9 +1246,9 @@ void shader_glsl_dst(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "%s = vec4(1.0, %s.x * %s.y, %s.z, %s.w)%s;\n",
dst_str, src0_reg, src1_reg, src0_reg, src1_reg, dst_mask);
......@@ -1273,8 +1269,8 @@ void shader_glsl_sincos(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50];
char dst_mask[6], src0_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_addline(arg->buffer, "%s = vec4(cos(%s), sin(%s), %s.z, %s.w)%s;\n",
dst_str, src0_str, src0_str, dst_reg, dst_reg, dst_mask);
......@@ -1291,7 +1287,7 @@ void shader_glsl_loop(SHADER_OPCODE_ARG* arg) {
char src1_reg[50];
char src1_mask[6];
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "for (tmpInt = 0, aL = %s.y; tmpInt < %s.x; tmpInt++, aL += %s.z) {\n",
src1_reg, src1_reg, src1_reg);
......@@ -1307,7 +1303,7 @@ void shader_glsl_rep(SHADER_OPCODE_ARG* arg) {
char src0_reg[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_addline(arg->buffer, "for (tmpInt = 0; tmpInt < %s.x; tmpInt++) {\n", src0_reg);
}
......@@ -1317,7 +1313,7 @@ void shader_glsl_if(SHADER_OPCODE_ARG* arg) {
char src0_reg[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_addline(arg->buffer, "if (%s) {\n", src0_str);
}
......@@ -1327,8 +1323,8 @@ void shader_glsl_ifc(SHADER_OPCODE_ARG* arg) {
char src0_reg[50], src1_reg[50];
char src0_mask[6], src1_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "if (%s %s %s) {\n",
src0_str, shader_get_comp_op(arg->opcode_token), src1_str);
......@@ -1348,8 +1344,8 @@ void shader_glsl_breakc(SHADER_OPCODE_ARG* arg) {
char src0_reg[50], src1_reg[50];
char src0_mask[6], src1_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "if (%s %s %s) break;\n",
src0_str, shader_get_comp_op(arg->opcode_token), src1_str);
......@@ -1374,7 +1370,7 @@ void shader_glsl_callnz(SHADER_OPCODE_ARG* arg) {
char src1_mask[6];
DWORD snum = (arg->src[0]) & WINED3DSP_REGNUM_MASK;
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_addline(arg->buffer, "if (%s) subroutine%lu();\n", src1_str, snum);
}
......@@ -1390,14 +1386,14 @@ void pshader_glsl_tex(SHADER_OPCODE_ARG* arg) {
char coord_str[100], coord_reg[50], coord_mask[6];
/* All versions have a destination register */
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
/* 1.0-1.3: Use destination register as coordinate source.
1.4+: Use provided coordinate source register. */
if (hex_version < WINED3DPS_VERSION(1,4))
strcpy(coord_reg, dst_reg);
else
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, coord_reg, coord_mask, coord_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], coord_reg, coord_mask, coord_str);
/* 1.0-1.4: Use destination register as sampler source.
* 2.0+: Use provided sampler source. */
......@@ -1422,7 +1418,7 @@ void pshader_glsl_texcoord(SHADER_OPCODE_ARG* arg) {
char tmpMask[6];
tmpReg[0] = 0;
shader_glsl_add_param(arg, arg->dst, 0, FALSE, tmpReg, tmpMask, tmpStr);
shader_glsl_add_dst_param(arg, arg->dst, 0, tmpReg, tmpMask, tmpStr);
if (hex_version != WINED3DPS_VERSION(1,4)) {
DWORD reg = arg->dst & WINED3DSP_REGNUM_MASK;
......@@ -1443,8 +1439,8 @@ void pshader_glsl_texdp3tex(SHADER_OPCODE_ARG* arg) {
char src0_name[50], dst_name[50];
char src0_mask[6], dst_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_name, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_name, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "tmp0.x = dot(vec3(gl_TexCoord[%u]), vec3(%s));\n", dstreg, src0_str);
shader_addline(arg->buffer, "%s = vec4(texture1D(Psampler%u, tmp0.x))%s;\n", dst_str, dstreg, dst_mask);
......@@ -1459,8 +1455,8 @@ void pshader_glsl_texdp3(SHADER_OPCODE_ARG* arg) {
char src0_name[50], dst_name[50];
char src0_mask[6], dst_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_name, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_name, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "%s = vec4(dot(vec3(T%u), vec3(%s)))%s;\n",
dst_str, dstreg, src0_str, dst_mask);
......@@ -1474,7 +1470,7 @@ void pshader_glsl_texdepth(SHADER_OPCODE_ARG* arg) {
char dst_reg[50];
char dst_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_addline(arg->buffer, "gl_FragDepth = %s.x / %s.y;\n", dst_reg, dst_reg);
}
......@@ -1491,8 +1487,8 @@ void pshader_glsl_texm3x2depth(SHADER_OPCODE_ARG* arg) {
char src0_name[50], dst_name[50];
char src0_mask[6], dst_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_name, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_name, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "tmp0.y = dot(vec3(T%u), vec3(%s));\n", dstreg, src0_str);
shader_addline(arg->buffer, "gl_FragDepth = vec4((tmp0.y == 0.0) ? 1.0 : tmp0.x / tmp0.y)%s;\n", dst_str, dst_name);
......@@ -1508,7 +1504,7 @@ void pshader_glsl_texm3x2pad(SHADER_OPCODE_ARG* arg) {
char src0_name[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(buffer, "tmp0.x = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
}
......@@ -1524,7 +1520,7 @@ void pshader_glsl_texm3x3pad(SHADER_OPCODE_ARG* arg) {
char src0_name[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(buffer, "tmp0.%c = dot(vec3(T%u), vec3(%s));\n", 'x' + current_state->current_row, reg, src0_str);
current_state->texcoord_w[current_state->current_row++] = reg;
}
......@@ -1537,7 +1533,7 @@ void pshader_glsl_texm3x2tex(SHADER_OPCODE_ARG* arg) {
char src0_name[50];
char src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(buffer, "tmp0.y = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
/* Sample the texture using the calculated coordinates */
......@@ -1556,7 +1552,7 @@ void pshader_glsl_texm3x3tex(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "tmp0.z = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
/* Sample the texture using the calculated coordinates */
......@@ -1576,7 +1572,7 @@ void pshader_glsl_texm3x3(SHADER_OPCODE_ARG* arg) {
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
SHADER_PARSE_STATE* current_state = &This->baseShader.parse_state;
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_addline(arg->buffer, "tmp0.z = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
shader_addline(arg->buffer, "T%u = vec4(tmp0.x, tmp0.y, tmp0.z, 1.0);\n", reg);
......@@ -1607,8 +1603,8 @@ void pshader_glsl_texm3x3spec(SHADER_OPCODE_ARG* arg) {
break;
}
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_name, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_name, src1_mask, src1_str);
/* Perform the last matrix multiply operation */
shader_addline(buffer, "tmp0.z = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
......@@ -1633,7 +1629,7 @@ void pshader_glsl_texm3x3vspec(SHADER_OPCODE_ARG* arg) {
char dst_str[8];
char src0_str[100], src0_name[50], src0_mask[6];
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_name, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_name, src0_mask, src0_str);
/* Perform the last matrix multiply operation */
shader_addline(buffer, "tmp0.z = dot(vec3(T%u), vec3(%s));\n", reg, src0_str);
......@@ -1677,8 +1673,8 @@ void pshader_glsl_texreg2ar(SHADER_OPCODE_ARG* arg) {
char dst_mask[6], src0_mask[6];
DWORD src0_regnum = arg->src[0] & WINED3DSP_REGNUM_MASK;
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%stexture2D(Psampler%u, %s.yz))%s;\n",
......@@ -1695,8 +1691,8 @@ void pshader_glsl_texreg2gb(SHADER_OPCODE_ARG* arg) {
char dst_mask[6], src0_mask[6];
DWORD src0_regnum = arg->src[0] & WINED3DSP_REGNUM_MASK;
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%stexture2D(Psampler%u, %s.yz))%s;\n",
......@@ -1724,8 +1720,8 @@ void pshader_glsl_texreg2rgb(SHADER_OPCODE_ARG* arg) {
break;
}
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%stexture%s(Psampler%u, %s.%s))%s;\n",
......@@ -1738,7 +1734,7 @@ void pshader_glsl_texkill(SHADER_OPCODE_ARG* arg) {
char dst_str[100], dst_name[50], dst_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_name, dst_mask, dst_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_name, dst_mask, dst_str);
shader_addline(arg->buffer, "if (any(lessThan(%s.xyz, vec3(0.0)))) discard;\n", dst_name);
}
......@@ -1751,10 +1747,10 @@ void pshader_glsl_dp2add(SHADER_OPCODE_ARG* arg) {
char dst_reg[50], src0_reg[50], src1_reg[50], src2_reg[50];
char dst_mask[6], src0_mask[6], src1_mask[6], src2_mask[6];
shader_glsl_add_param(arg, arg->dst, 0, FALSE, dst_reg, dst_mask, dst_str);
shader_glsl_add_param(arg, arg->src[0], arg->src_addr[0], TRUE, src0_reg, src0_mask, src0_str);
shader_glsl_add_param(arg, arg->src[1], arg->src_addr[1], TRUE, src1_reg, src1_mask, src1_str);
shader_glsl_add_param(arg, arg->src[2], arg->src_addr[2], TRUE, src2_reg, src2_mask, src2_str);
shader_glsl_add_dst_param(arg, arg->dst, 0, dst_reg, dst_mask, dst_str);
shader_glsl_add_src_param(arg, arg->src[0], arg->src_addr[0], src0_reg, src0_mask, src0_str);
shader_glsl_add_src_param(arg, arg->src[1], arg->src_addr[1], src1_reg, src1_mask, src1_str);
shader_glsl_add_src_param(arg, arg->src[2], arg->src_addr[2], src2_reg, src2_mask, src2_str);
shader_glsl_add_dst(arg->dst, dst_reg, dst_mask, tmpLine);
shader_addline(arg->buffer, "%sdot(vec2(%s), vec2(%s)) + %s)%s;\n",
tmpLine, src0_str, src1_str, src2_str, dst_mask);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment