2006-05-08 21:44:25 +02:00
|
|
|
/*
|
|
|
|
* shaders implementation
|
|
|
|
*
|
|
|
|
* Copyright 2002-2003 Jason Edmeades
|
|
|
|
* Copyright 2002-2003 Raphael Junqueira
|
2006-07-17 20:35:14 +02:00
|
|
|
* Copyright 2004 Christian Costa
|
2006-05-08 21:44:25 +02:00
|
|
|
* Copyright 2005 Oliver Stieber
|
2006-05-17 08:04:30 +02:00
|
|
|
* Copyright 2006 Ivan Gyurdiev
|
2008-10-18 19:21:20 +02:00
|
|
|
* Copyright 2007-2008 Stefan Dösinger for CodeWeavers
|
2009-04-17 09:46:56 +02:00
|
|
|
* Copyright 2009 Henri Verbeet for CodeWeavers
|
2006-05-08 21:44:25 +02: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
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2006-05-08 21:44:25 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include <string.h>
|
|
|
|
#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);
|
2006-05-08 21:44:25 +02:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
static const char *shader_opcode_names[] =
|
|
|
|
{
|
|
|
|
/* WINED3DSIH_ABS */ "abs",
|
|
|
|
/* WINED3DSIH_ADD */ "add",
|
|
|
|
/* WINED3DSIH_BEM */ "bem",
|
|
|
|
/* WINED3DSIH_BREAK */ "break",
|
|
|
|
/* WINED3DSIH_BREAKC */ "breakc",
|
|
|
|
/* WINED3DSIH_BREAKP */ "breakp",
|
|
|
|
/* WINED3DSIH_CALL */ "call",
|
|
|
|
/* WINED3DSIH_CALLNZ */ "callnz",
|
|
|
|
/* WINED3DSIH_CMP */ "cmp",
|
|
|
|
/* WINED3DSIH_CND */ "cnd",
|
|
|
|
/* WINED3DSIH_CRS */ "crs",
|
|
|
|
/* WINED3DSIH_DCL */ "dcl",
|
|
|
|
/* WINED3DSIH_DEF */ "def",
|
|
|
|
/* WINED3DSIH_DEFB */ "defb",
|
|
|
|
/* WINED3DSIH_DEFI */ "defi",
|
|
|
|
/* WINED3DSIH_DP2ADD */ "dp2add",
|
|
|
|
/* WINED3DSIH_DP3 */ "dp3",
|
|
|
|
/* WINED3DSIH_DP4 */ "dp4",
|
|
|
|
/* WINED3DSIH_DST */ "dst",
|
|
|
|
/* WINED3DSIH_DSX */ "dsx",
|
|
|
|
/* WINED3DSIH_DSY */ "dsy",
|
|
|
|
/* WINED3DSIH_ELSE */ "else",
|
|
|
|
/* WINED3DSIH_ENDIF */ "endif",
|
|
|
|
/* WINED3DSIH_ENDLOOP */ "endloop",
|
|
|
|
/* WINED3DSIH_ENDREP */ "endrep",
|
|
|
|
/* WINED3DSIH_EXP */ "exp",
|
|
|
|
/* WINED3DSIH_EXPP */ "expp",
|
|
|
|
/* WINED3DSIH_FRC */ "frc",
|
|
|
|
/* WINED3DSIH_IF */ "if",
|
|
|
|
/* WINED3DSIH_IFC */ "ifc",
|
|
|
|
/* WINED3DSIH_LABEL */ "label",
|
|
|
|
/* WINED3DSIH_LIT */ "lit",
|
|
|
|
/* WINED3DSIH_LOG */ "log",
|
|
|
|
/* WINED3DSIH_LOGP */ "logp",
|
|
|
|
/* WINED3DSIH_LOOP */ "loop",
|
|
|
|
/* WINED3DSIH_LRP */ "lrp",
|
|
|
|
/* WINED3DSIH_M3x2 */ "m3x2",
|
|
|
|
/* WINED3DSIH_M3x3 */ "m3x3",
|
|
|
|
/* WINED3DSIH_M3x4 */ "m3x4",
|
|
|
|
/* WINED3DSIH_M4x3 */ "m4x3",
|
|
|
|
/* WINED3DSIH_M4x4 */ "m4x4",
|
|
|
|
/* WINED3DSIH_MAD */ "mad",
|
|
|
|
/* WINED3DSIH_MAX */ "max",
|
|
|
|
/* WINED3DSIH_MIN */ "min",
|
|
|
|
/* WINED3DSIH_MOV */ "mov",
|
|
|
|
/* WINED3DSIH_MOVA */ "mova",
|
|
|
|
/* WINED3DSIH_MUL */ "mul",
|
|
|
|
/* WINED3DSIH_NOP */ "nop",
|
|
|
|
/* WINED3DSIH_NRM */ "nrm",
|
|
|
|
/* WINED3DSIH_PHASE */ "phase",
|
|
|
|
/* WINED3DSIH_POW */ "pow",
|
|
|
|
/* WINED3DSIH_RCP */ "rcp",
|
|
|
|
/* WINED3DSIH_REP */ "rep",
|
|
|
|
/* WINED3DSIH_RET */ "ret",
|
|
|
|
/* WINED3DSIH_RSQ */ "rsq",
|
|
|
|
/* WINED3DSIH_SETP */ "setp",
|
|
|
|
/* WINED3DSIH_SGE */ "sge",
|
|
|
|
/* WINED3DSIH_SGN */ "sgn",
|
|
|
|
/* WINED3DSIH_SINCOS */ "sincos",
|
|
|
|
/* WINED3DSIH_SLT */ "slt",
|
|
|
|
/* WINED3DSIH_SUB */ "sub",
|
|
|
|
/* WINED3DSIH_TEX */ "texld",
|
|
|
|
/* WINED3DSIH_TEXBEM */ "texbem",
|
|
|
|
/* WINED3DSIH_TEXBEML */ "texbeml",
|
|
|
|
/* WINED3DSIH_TEXCOORD */ "texcrd",
|
|
|
|
/* WINED3DSIH_TEXDEPTH */ "texdepth",
|
|
|
|
/* WINED3DSIH_TEXDP3 */ "texdp3",
|
|
|
|
/* WINED3DSIH_TEXDP3TEX */ "texdp3tex",
|
|
|
|
/* WINED3DSIH_TEXKILL */ "texkill",
|
|
|
|
/* WINED3DSIH_TEXLDD */ "texldd",
|
|
|
|
/* WINED3DSIH_TEXLDL */ "texldl",
|
|
|
|
/* WINED3DSIH_TEXM3x2DEPTH */ "texm3x2depth",
|
|
|
|
/* WINED3DSIH_TEXM3x2PAD */ "texm3x2pad",
|
|
|
|
/* WINED3DSIH_TEXM3x2TEX */ "texm3x2tex",
|
|
|
|
/* WINED3DSIH_TEXM3x3 */ "texm3x3",
|
|
|
|
/* WINED3DSIH_TEXM3x3DIFF */ "texm3x3diff",
|
|
|
|
/* WINED3DSIH_TEXM3x3PAD */ "texm3x3pad",
|
|
|
|
/* WINED3DSIH_TEXM3x3SPEC */ "texm3x3spec",
|
|
|
|
/* WINED3DSIH_TEXM3x3TEX */ "texm3x3tex",
|
|
|
|
/* WINED3DSIH_TEXM3x3VSPEC */ "texm3x3vspec",
|
|
|
|
/* WINED3DSIH_TEXREG2AR */ "texreg2ar",
|
|
|
|
/* WINED3DSIH_TEXREG2GB */ "texreg2gb",
|
|
|
|
/* WINED3DSIH_TEXREG2RGB */ "texreg2rgb",
|
|
|
|
};
|
|
|
|
|
2009-05-04 09:49:27 +02:00
|
|
|
const struct wined3d_shader_frontend *shader_select_frontend(DWORD version_token)
|
|
|
|
{
|
|
|
|
switch (version_token >> 16)
|
|
|
|
{
|
|
|
|
case WINED3D_SM1_VS:
|
|
|
|
case WINED3D_SM1_PS:
|
|
|
|
return &sm1_shader_frontend;
|
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
case WINED3D_SM4_PS:
|
|
|
|
case WINED3D_SM4_VS:
|
|
|
|
case WINED3D_SM4_GS:
|
|
|
|
return &sm4_shader_frontend;
|
|
|
|
|
2009-05-04 09:49:27 +02:00
|
|
|
default:
|
|
|
|
FIXME("Unrecognised version token %#x\n", version_token);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:08 +02:00
|
|
|
void shader_buffer_clear(struct wined3d_shader_buffer *buffer)
|
2008-12-09 09:52:38 +01:00
|
|
|
{
|
|
|
|
buffer->buffer[0] = '\0';
|
|
|
|
buffer->bsize = 0;
|
|
|
|
buffer->lineNo = 0;
|
|
|
|
buffer->newline = TRUE;
|
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:09 +02:00
|
|
|
BOOL shader_buffer_init(struct wined3d_shader_buffer *buffer)
|
2009-07-09 09:56:07 +02:00
|
|
|
{
|
|
|
|
buffer->buffer = HeapAlloc(GetProcessHeap(), 0, SHADER_PGMSIZE);
|
2009-07-09 09:56:09 +02:00
|
|
|
if (!buffer->buffer)
|
|
|
|
{
|
|
|
|
ERR("Failed to allocate shader buffer memory.\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:07 +02:00
|
|
|
shader_buffer_clear(buffer);
|
2009-07-09 09:56:09 +02:00
|
|
|
return TRUE;
|
2009-07-09 09:56:07 +02:00
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:08 +02:00
|
|
|
void shader_buffer_free(struct wined3d_shader_buffer *buffer)
|
2008-12-09 09:52:38 +01:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, buffer->buffer);
|
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:08 +02:00
|
|
|
int shader_vaddline(struct wined3d_shader_buffer *buffer, const char *format, va_list args)
|
2009-03-10 09:19:04 +01:00
|
|
|
{
|
2006-05-08 21:44:25 +02:00
|
|
|
char* base = buffer->buffer + buffer->bsize;
|
|
|
|
int rc;
|
|
|
|
|
|
|
|
rc = vsnprintf(base, SHADER_PGMSIZE - 1 - buffer->bsize, format, args);
|
|
|
|
|
2009-07-08 09:49:29 +02:00
|
|
|
if (rc < 0 /* C89 */ || (unsigned int)rc > SHADER_PGMSIZE - 1 - buffer->bsize /* C99 */)
|
|
|
|
{
|
2006-05-08 21:44:25 +02:00
|
|
|
ERR("The buffer allocated for the shader program string "
|
|
|
|
"is too small at %d bytes.\n", SHADER_PGMSIZE);
|
|
|
|
buffer->bsize = SHADER_PGMSIZE - 1;
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2007-01-15 19:30:41 +01:00
|
|
|
if (buffer->newline) {
|
|
|
|
TRACE("GL HW (%u, %u) : %s", buffer->lineNo + 1, buffer->bsize, base);
|
|
|
|
buffer->newline = FALSE;
|
|
|
|
} else {
|
2007-01-18 23:41:27 +01:00
|
|
|
TRACE("%s", base);
|
2007-01-15 19:30:41 +01:00
|
|
|
}
|
|
|
|
|
2006-05-08 21:44:25 +02:00
|
|
|
buffer->bsize += rc;
|
2007-01-15 19:30:41 +01:00
|
|
|
if (buffer->buffer[buffer->bsize-1] == '\n') {
|
|
|
|
buffer->lineNo++;
|
|
|
|
buffer->newline = TRUE;
|
|
|
|
}
|
2006-05-08 21:44:25 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2009-07-09 09:56:08 +02:00
|
|
|
int shader_addline(struct wined3d_shader_buffer *buffer, const char *format, ...)
|
2009-03-10 09:19:04 +01:00
|
|
|
{
|
|
|
|
int ret;
|
|
|
|
va_list args;
|
|
|
|
|
|
|
|
va_start(args, format);
|
|
|
|
ret = shader_vaddline(buffer, format, args);
|
|
|
|
va_end(args);
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2009-09-25 13:31:44 +02:00
|
|
|
void shader_init(struct IWineD3DBaseShaderClass *shader, IWineD3DDeviceImpl *device,
|
|
|
|
IUnknown *parent, const struct wined3d_parent_ops *parent_ops)
|
2009-01-12 10:17:50 +01:00
|
|
|
{
|
|
|
|
shader->ref = 1;
|
2009-09-25 13:31:44 +02:00
|
|
|
shader->device = (IWineD3DDevice *)device;
|
|
|
|
shader->parent = parent;
|
|
|
|
shader->parent_ops = parent_ops;
|
2009-01-12 10:17:50 +01:00
|
|
|
list_init(&shader->linked_programs);
|
2009-09-25 13:31:44 +02:00
|
|
|
list_add_head(&device->shaders, &shader->shader_list_entry);
|
2009-01-12 10:17:50 +01:00
|
|
|
}
|
|
|
|
|
2006-06-06 08:40:08 +02:00
|
|
|
/* Convert floating point offset relative
|
|
|
|
* to a register file to an absolute offset for float constants */
|
2009-04-30 11:02:19 +02:00
|
|
|
static unsigned int shader_get_float_offset(WINED3DSHADER_PARAM_REGISTER_TYPE register_type, UINT register_idx)
|
2008-12-02 18:41:33 +01:00
|
|
|
{
|
2009-04-30 11:02:19 +02:00
|
|
|
switch (register_type)
|
|
|
|
{
|
|
|
|
case WINED3DSPR_CONST: return register_idx;
|
|
|
|
case WINED3DSPR_CONST2: return 2048 + register_idx;
|
|
|
|
case WINED3DSPR_CONST3: return 4096 + register_idx;
|
|
|
|
case WINED3DSPR_CONST4: return 6144 + register_idx;
|
2006-06-06 08:40:08 +02:00
|
|
|
default:
|
2009-04-30 11:02:19 +02:00
|
|
|
FIXME("Unsupported register type: %d\n", register_type);
|
|
|
|
return register_idx;
|
|
|
|
}
|
2006-06-06 08:40:08 +02:00
|
|
|
}
|
|
|
|
|
2008-01-08 22:31:24 +01:00
|
|
|
static void shader_delete_constant_list(struct list* clist) {
|
|
|
|
|
|
|
|
struct list *ptr;
|
|
|
|
struct local_constant* constant;
|
|
|
|
|
|
|
|
ptr = list_head(clist);
|
|
|
|
while (ptr) {
|
|
|
|
constant = LIST_ENTRY(ptr, struct local_constant, entry);
|
|
|
|
ptr = list_next(clist, ptr);
|
|
|
|
HeapFree(GetProcessHeap(), 0, constant);
|
|
|
|
}
|
|
|
|
list_init(clist);
|
|
|
|
}
|
|
|
|
|
2009-05-07 17:31:20 +02:00
|
|
|
static inline void set_bitmap_bit(DWORD *bitmap, DWORD bit)
|
|
|
|
{
|
|
|
|
DWORD idx, shift;
|
|
|
|
idx = bit >> 5;
|
|
|
|
shift = bit & 0x1f;
|
|
|
|
bitmap[idx] |= (1 << shift);
|
|
|
|
}
|
|
|
|
|
2009-04-28 09:53:28 +02:00
|
|
|
static void shader_record_register_usage(IWineD3DBaseShaderImpl *This, struct shader_reg_maps *reg_maps,
|
2009-06-30 12:18:26 +02:00
|
|
|
const struct wined3d_shader_register *reg, enum wined3d_shader_type shader_type)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
switch (reg->type)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
|
|
|
case WINED3DSPR_TEXTURE: /* WINED3DSPR_ADDR */
|
2009-08-11 09:42:15 +02:00
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL) reg_maps->texcoord |= 1 << reg->idx;
|
2009-08-12 09:44:23 +02:00
|
|
|
else reg_maps->address |= 1 << reg->idx;
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_TEMP:
|
2009-08-11 09:42:16 +02:00
|
|
|
reg_maps->temporary |= 1 << reg->idx;
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_INPUT:
|
2009-06-30 12:18:26 +02:00
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
if (reg->rel_addr)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
|
|
|
/* If relative addressing is used, we must assume that all registers
|
|
|
|
* are used. Even if it is a construct like v3[aL], we can't assume
|
|
|
|
* that v0, v1 and v2 aren't read because aL can be negative */
|
|
|
|
unsigned int i;
|
|
|
|
for (i = 0; i < MAX_REG_INPUT; ++i)
|
|
|
|
{
|
|
|
|
((IWineD3DPixelShaderImpl *)This)->input_reg_used[i] = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
((IWineD3DPixelShaderImpl *)This)->input_reg_used[reg->idx] = TRUE;
|
2009-04-28 09:53:28 +02:00
|
|
|
}
|
|
|
|
}
|
2009-06-30 12:18:26 +02:00
|
|
|
else reg_maps->input_registers |= 1 << reg->idx;
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_RASTOUT:
|
2009-05-11 16:43:49 +02:00
|
|
|
if (reg->idx == 1) reg_maps->fog = 1;
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_MISCTYPE:
|
2009-06-30 12:18:26 +02:00
|
|
|
if (shader_type == WINED3D_SHADER_TYPE_PIXEL)
|
|
|
|
{
|
|
|
|
if (reg->idx == 0) reg_maps->vpos = 1;
|
|
|
|
else if (reg->idx == 1) reg_maps->usesfacing = 1;
|
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONST:
|
2009-05-11 16:43:49 +02:00
|
|
|
if (reg->rel_addr)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
2009-06-30 12:18:26 +02:00
|
|
|
if (shader_type != WINED3D_SHADER_TYPE_PIXEL)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
2009-07-08 09:20:12 +02:00
|
|
|
if (reg->idx < ((IWineD3DVertexShaderImpl *)This)->min_rel_offset)
|
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
((IWineD3DVertexShaderImpl *)This)->min_rel_offset = reg->idx;
|
2009-07-08 09:20:12 +02:00
|
|
|
}
|
|
|
|
if (reg->idx > ((IWineD3DVertexShaderImpl *)This)->max_rel_offset)
|
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
((IWineD3DVertexShaderImpl *)This)->max_rel_offset = reg->idx;
|
2009-07-08 09:20:12 +02:00
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
}
|
|
|
|
reg_maps->usesrelconstF = TRUE;
|
|
|
|
}
|
2009-05-07 17:31:20 +02:00
|
|
|
else
|
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
set_bitmap_bit(reg_maps->constf, reg->idx);
|
2009-05-07 17:31:20 +02:00
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTINT:
|
2009-05-11 16:43:49 +02:00
|
|
|
reg_maps->integer_constants |= (1 << reg->idx);
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3DSPR_CONSTBOOL:
|
2009-05-11 16:43:49 +02:00
|
|
|
reg_maps->boolean_constants |= (1 << reg->idx);
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
|
2009-06-18 18:10:15 +02:00
|
|
|
case WINED3DSPR_COLOROUT:
|
|
|
|
reg_maps->highest_render_target = max(reg_maps->highest_render_target, reg->idx);
|
|
|
|
break;
|
|
|
|
|
2009-04-28 09:53:28 +02:00
|
|
|
default:
|
2009-05-11 16:43:49 +02:00
|
|
|
TRACE("Not recording register of type %#x and idx %u\n", reg->type, reg->idx);
|
2009-04-28 09:53:28 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
static unsigned int get_instr_extra_regcount(enum WINED3D_SHADER_INSTRUCTION_HANDLER instr, unsigned int param)
|
2009-05-07 17:31:20 +02:00
|
|
|
{
|
|
|
|
switch(instr)
|
|
|
|
{
|
|
|
|
case WINED3DSIH_M4x4:
|
|
|
|
case WINED3DSIH_M3x4:
|
2009-05-11 16:43:49 +02:00
|
|
|
return param == 1 ? 3 : 0;
|
2009-05-07 17:31:20 +02:00
|
|
|
|
|
|
|
case WINED3DSIH_M4x3:
|
|
|
|
case WINED3DSIH_M3x3:
|
2009-05-11 16:43:49 +02:00
|
|
|
return param == 1 ? 2 : 0;
|
2009-05-07 17:31:20 +02:00
|
|
|
|
|
|
|
case WINED3DSIH_M3x2:
|
2009-05-11 16:43:49 +02:00
|
|
|
return param == 1 ? 1 : 0;
|
2009-05-07 17:31:20 +02:00
|
|
|
|
|
|
|
default:
|
2009-05-11 16:43:49 +02:00
|
|
|
return 0;
|
2009-05-07 17:31:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-27 10:24:50 +02:00
|
|
|
static const char *shader_semantic_name_from_usage(WINED3DDECLUSAGE usage)
|
|
|
|
{
|
|
|
|
static const char *semantic_names[] =
|
|
|
|
{
|
2009-05-28 08:44:21 +02:00
|
|
|
/* WINED3DDECLUSAGE_POSITION */ "SV_POSITION",
|
2009-05-27 10:24:50 +02:00
|
|
|
/* WINED3DDECLUSAGE_BLENDWEIGHT */ "BLENDWEIGHT",
|
|
|
|
/* WINED3DDECLUSAGE_BLENDINDICES */ "BLENDINDICES",
|
|
|
|
/* WINED3DDECLUSAGE_NORMAL */ "NORMAL",
|
|
|
|
/* WINED3DDECLUSAGE_PSIZE */ "PSIZE",
|
|
|
|
/* WINED3DDECLUSAGE_TEXCOORD */ "TEXCOORD",
|
|
|
|
/* WINED3DDECLUSAGE_TANGENT */ "TANGENT",
|
|
|
|
/* WINED3DDECLUSAGE_BINORMAL */ "BINORMAL",
|
|
|
|
/* WINED3DDECLUSAGE_TESSFACTOR */ "TESSFACTOR",
|
|
|
|
/* WINED3DDECLUSAGE_POSITIONT */ "POSITIONT",
|
|
|
|
/* WINED3DDECLUSAGE_COLOR */ "COLOR",
|
|
|
|
/* WINED3DDECLUSAGE_FOG */ "FOG",
|
|
|
|
/* WINED3DDECLUSAGE_DEPTH */ "DEPTH",
|
|
|
|
/* WINED3DDECLUSAGE_SAMPLE */ "SAMPLE",
|
|
|
|
};
|
|
|
|
|
|
|
|
if (usage >= sizeof(semantic_names) / sizeof(*semantic_names))
|
|
|
|
{
|
|
|
|
FIXME("Unrecognized usage %#x\n", usage);
|
|
|
|
return "UNRECOGNIZED";
|
|
|
|
}
|
|
|
|
|
|
|
|
return semantic_names[usage];
|
|
|
|
}
|
|
|
|
|
|
|
|
BOOL shader_match_semantic(const char *semantic_name, WINED3DDECLUSAGE usage)
|
|
|
|
{
|
|
|
|
return !strcmp(semantic_name, shader_semantic_name_from_usage(usage));
|
|
|
|
}
|
|
|
|
|
|
|
|
static void shader_signature_from_semantic(struct wined3d_shader_signature_element *e,
|
|
|
|
const struct wined3d_shader_semantic *s)
|
|
|
|
{
|
|
|
|
e->semantic_name = shader_semantic_name_from_usage(s->usage);
|
|
|
|
e->semantic_idx = s->usage_idx;
|
|
|
|
e->sysval_semantic = 0;
|
|
|
|
e->component_type = 0;
|
|
|
|
e->register_idx = s->reg.reg.idx;
|
|
|
|
e->mask = s->reg.write_mask;
|
|
|
|
}
|
|
|
|
|
2006-05-21 23:16:17 +02:00
|
|
|
/* Note that this does not count the loop register
|
|
|
|
* as an address register. */
|
2006-05-10 00:03:09 +02:00
|
|
|
|
2009-05-04 09:49:27 +02:00
|
|
|
HRESULT shader_get_registers_used(IWineD3DBaseShader *iface, const struct wined3d_shader_frontend *fe,
|
2009-05-27 10:24:50 +02:00
|
|
|
struct shader_reg_maps *reg_maps, struct wined3d_shader_attribute *attributes,
|
2009-05-27 10:24:50 +02:00
|
|
|
struct wined3d_shader_signature_element *input_signature,
|
|
|
|
struct wined3d_shader_signature_element *output_signature, const DWORD *byte_code, DWORD constf_size)
|
2008-12-11 11:52:37 +01:00
|
|
|
{
|
2006-05-10 04:31:09 +02:00
|
|
|
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
|
2009-05-05 09:38:03 +02:00
|
|
|
void *fe_data = This->baseShader.frontend_data;
|
2009-05-06 17:59:21 +02:00
|
|
|
struct wined3d_shader_version shader_version;
|
2007-09-14 13:21:52 +02:00
|
|
|
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
|
2008-12-11 11:52:37 +01:00
|
|
|
const DWORD* pToken = byte_code;
|
2006-05-10 00:03:09 +02:00
|
|
|
|
2006-06-12 08:55:30 +02:00
|
|
|
/* There are some minor differences between pixel and vertex shaders */
|
|
|
|
|
2009-04-28 09:53:29 +02:00
|
|
|
memset(reg_maps, 0, sizeof(*reg_maps));
|
2007-03-26 23:34:32 +02:00
|
|
|
|
2008-01-08 22:31:24 +01:00
|
|
|
/* get_registers_used is called on every compile on some 1.x shaders, which can result
|
|
|
|
* in stacking up a collection of local constants. Delete the old constants if existing
|
|
|
|
*/
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsF);
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsB);
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsI);
|
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
fe->shader_read_header(fe_data, &pToken, &shader_version);
|
2009-05-05 09:38:03 +02:00
|
|
|
reg_maps->shader_version = shader_version;
|
2008-12-11 11:52:37 +01:00
|
|
|
|
2009-05-07 17:31:20 +02:00
|
|
|
reg_maps->constf = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(*reg_maps->constf) * ((constf_size + 31) / 32));
|
|
|
|
if(!reg_maps->constf) {
|
|
|
|
ERR("Out of memory\n");
|
|
|
|
return E_OUTOFMEMORY;
|
|
|
|
}
|
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
while (!fe->shader_is_end(fe_data, &pToken))
|
2009-05-04 09:49:27 +02:00
|
|
|
{
|
2009-04-24 09:17:58 +02:00
|
|
|
struct wined3d_shader_instruction ins;
|
2009-05-01 09:13:54 +02:00
|
|
|
const char *comment;
|
2009-04-24 09:17:58 +02:00
|
|
|
UINT param_size;
|
2006-05-10 00:03:09 +02:00
|
|
|
|
|
|
|
/* Skip comments */
|
2009-05-04 09:49:27 +02:00
|
|
|
fe->shader_read_comment(&pToken, &comment);
|
2009-05-01 09:13:54 +02:00
|
|
|
if (comment) continue;
|
2006-05-10 00:03:09 +02:00
|
|
|
|
|
|
|
/* Fetch opcode */
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size);
|
2006-05-10 00:03:09 +02:00
|
|
|
|
|
|
|
/* Unhandled opcode, and its parameters */
|
2009-04-24 09:17:58 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
|
|
|
{
|
|
|
|
TRACE("Skipping unrecognized instruction.\n");
|
|
|
|
pToken += param_size;
|
|
|
|
continue;
|
|
|
|
}
|
2006-05-10 00:03:09 +02:00
|
|
|
|
2006-06-12 08:53:32 +02:00
|
|
|
/* Handle declarations */
|
2009-04-24 09:17:58 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_DCL)
|
|
|
|
{
|
2009-04-29 09:55:07 +02:00
|
|
|
struct wined3d_shader_semantic semantic;
|
2006-06-12 08:53:32 +02:00
|
|
|
|
2009-05-04 09:49:27 +02:00
|
|
|
fe->shader_read_semantic(&pToken, &semantic);
|
2006-06-12 08:55:30 +02:00
|
|
|
|
2009-05-07 16:36:07 +02:00
|
|
|
switch (semantic.reg.reg.type)
|
2009-04-29 09:55:07 +02:00
|
|
|
{
|
|
|
|
/* Vshader: mark attributes used
|
|
|
|
* Pshader: mark 3.0 input registers used, save token */
|
|
|
|
case WINED3DSPR_INPUT:
|
2009-05-27 10:24:49 +02:00
|
|
|
reg_maps->input_registers |= 1 << semantic.reg.reg.idx;
|
2009-05-27 10:24:50 +02:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX)
|
|
|
|
{
|
|
|
|
attributes[semantic.reg.reg.idx].usage = semantic.usage;
|
|
|
|
attributes[semantic.reg.reg.idx].usage_idx = semantic.usage_idx;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-27 10:24:50 +02:00
|
|
|
shader_signature_from_semantic(&input_signature[semantic.reg.reg.idx], &semantic);
|
2009-05-27 10:24:50 +02:00
|
|
|
}
|
2009-04-29 09:55:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
/* Vshader: mark 3.0 output registers used, save token */
|
|
|
|
case WINED3DSPR_OUTPUT:
|
2009-05-27 10:24:50 +02:00
|
|
|
reg_maps->output_registers |= 1 << semantic.reg.reg.idx;
|
2009-05-27 10:24:50 +02:00
|
|
|
shader_signature_from_semantic(&output_signature[semantic.reg.reg.idx], &semantic);
|
2009-04-29 09:55:07 +02:00
|
|
|
if (semantic.usage == WINED3DDECLUSAGE_FOG) reg_maps->fog = 1;
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* Save sampler usage token */
|
|
|
|
case WINED3DSPR_SAMPLER:
|
2009-05-07 16:36:07 +02:00
|
|
|
reg_maps->sampler_type[semantic.reg.reg.idx] = semantic.sampler_type;
|
2009-04-29 09:55:07 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-05-07 16:36:07 +02:00
|
|
|
TRACE("Not recording DCL register type %#x.\n", semantic.reg.reg.type);
|
2009-04-29 09:55:07 +02:00
|
|
|
break;
|
|
|
|
}
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEF)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
|
|
|
|
if (!lconst) return E_OUTOFMEMORY;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-05-07 16:36:07 +02:00
|
|
|
lconst->idx = dst.reg.idx;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
|
|
|
memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
|
|
|
|
pToken += 4;
|
2007-09-13 13:34:29 +02:00
|
|
|
|
|
|
|
/* In pixel shader 1.X shaders, the constants are clamped between [-1;1] */
|
2009-07-01 09:46:15 +02:00
|
|
|
if (shader_version.major == 1 && shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
2008-12-15 12:10:14 +01:00
|
|
|
{
|
2007-09-13 13:34:29 +02:00
|
|
|
float *value = (float *) lconst->value;
|
2009-07-07 11:08:01 +02:00
|
|
|
if (value[0] < -1.0f) value[0] = -1.0f;
|
|
|
|
else if (value[0] > 1.0f) value[0] = 1.0f;
|
|
|
|
if (value[1] < -1.0f) value[1] = -1.0f;
|
|
|
|
else if (value[1] > 1.0f) value[1] = 1.0f;
|
|
|
|
if (value[2] < -1.0f) value[2] = -1.0f;
|
|
|
|
else if (value[2] > 1.0f) value[2] = 1.0f;
|
|
|
|
if (value[3] < -1.0f) value[3] = -1.0f;
|
|
|
|
else if (value[3] > 1.0f) value[3] = 1.0f;
|
2007-09-13 13:34:29 +02:00
|
|
|
}
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
list_add_head(&This->baseShader.constantsF, &lconst->entry);
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFI)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
|
|
|
|
if (!lconst) return E_OUTOFMEMORY;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-05-07 16:36:07 +02:00
|
|
|
lconst->idx = dst.reg.idx;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
|
|
|
memcpy(lconst->value, pToken, 4 * sizeof(DWORD));
|
|
|
|
pToken += 4;
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
list_add_head(&This->baseShader.constantsI, &lconst->entry);
|
2009-06-16 07:36:59 +02:00
|
|
|
reg_maps->local_int_consts |= (1 << dst.reg.idx);
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFB)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
local_constant* lconst = HeapAlloc(GetProcessHeap(), 0, sizeof(local_constant));
|
|
|
|
if (!lconst) return E_OUTOFMEMORY;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-05-07 16:36:07 +02:00
|
|
|
lconst->idx = dst.reg.idx;
|
2009-05-01 09:13:54 +02:00
|
|
|
|
|
|
|
memcpy(lconst->value, pToken, sizeof(DWORD));
|
|
|
|
++pToken;
|
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
list_add_head(&This->baseShader.constantsB, &lconst->entry);
|
2009-05-27 18:23:59 +02:00
|
|
|
reg_maps->local_bool_consts |= (1 << dst.reg.idx);
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
2006-06-16 22:13:01 +02:00
|
|
|
/* If there's a loop in the shader */
|
2009-04-24 09:17:58 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_LOOP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_REP)
|
|
|
|
{
|
2009-05-04 09:49:27 +02:00
|
|
|
struct wined3d_shader_src_param src, rel_addr;
|
2009-04-22 21:39:14 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
|
2009-05-04 09:49:27 +02:00
|
|
|
|
|
|
|
/* Rep and Loop always use an integer constant for the control parameters */
|
|
|
|
if (ins.handler_idx == WINED3DSIH_REP)
|
|
|
|
{
|
2009-05-07 16:36:07 +02:00
|
|
|
reg_maps->integer_constants |= 1 << src.reg.idx;
|
2009-05-04 09:49:27 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
|
2009-05-07 16:36:07 +02:00
|
|
|
reg_maps->integer_constants |= 1 << src.reg.idx;
|
2009-04-22 21:39:14 +02:00
|
|
|
}
|
|
|
|
|
2007-09-14 13:21:52 +02:00
|
|
|
cur_loop_depth++;
|
|
|
|
if(cur_loop_depth > max_loop_depth)
|
|
|
|
max_loop_depth = cur_loop_depth;
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_ENDLOOP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_ENDREP)
|
|
|
|
{
|
2007-09-14 13:21:52 +02:00
|
|
|
cur_loop_depth--;
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
2006-07-10 12:35:15 +02:00
|
|
|
/* For subroutine prototypes */
|
2009-04-24 09:17:58 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_LABEL)
|
|
|
|
{
|
2009-05-04 09:49:27 +02:00
|
|
|
struct wined3d_shader_src_param src, rel_addr;
|
2006-07-10 12:35:15 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src, &rel_addr);
|
2009-08-12 09:44:24 +02:00
|
|
|
reg_maps->labels |= 1 << src.reg.idx;
|
2009-04-24 09:17:58 +02:00
|
|
|
}
|
2006-06-12 08:59:16 +02:00
|
|
|
/* Set texture, address, temporary registers */
|
2009-04-24 09:17:58 +02:00
|
|
|
else
|
|
|
|
{
|
2006-05-18 03:09:56 +02:00
|
|
|
int i, limit;
|
2009-05-26 15:53:52 +02:00
|
|
|
BOOL color0_mov = FALSE;
|
2006-05-10 00:03:09 +02:00
|
|
|
|
2006-05-18 03:09:56 +02:00
|
|
|
/* This will loop over all the registers and try to
|
2009-04-28 09:53:28 +02:00
|
|
|
* make a bitmask of the ones we're interested in.
|
2006-05-18 03:09:56 +02:00
|
|
|
*
|
2009-04-28 09:53:28 +02:00
|
|
|
* Relative addressing tokens are ignored, but that's
|
|
|
|
* okay, since we'll catch any address registers when
|
2006-05-18 03:09:56 +02:00
|
|
|
* they are initialized (required by spec) */
|
|
|
|
|
2009-04-28 09:53:28 +02:00
|
|
|
if (ins.dst_count)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_dst_param dst_param;
|
|
|
|
struct wined3d_shader_src_param dst_rel_addr;
|
2006-05-17 08:04:30 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
|
2006-05-17 08:04:30 +02:00
|
|
|
|
2009-06-30 10:58:15 +02:00
|
|
|
shader_record_register_usage(This, reg_maps, &dst_param.reg, shader_version.type);
|
|
|
|
|
2009-04-28 09:53:28 +02:00
|
|
|
/* WINED3DSPR_TEXCRDOUT is the same as WINED3DSPR_OUTPUT. _OUTPUT can be > MAX_REG_TEXCRD and
|
|
|
|
* is used in >= 3.0 shaders. Filter 3.0 shaders to prevent overflows, and also filter pixel
|
|
|
|
* shaders because TECRDOUT isn't used in them, but future register types might cause issues */
|
2009-07-01 09:46:15 +02:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_VERTEX && shader_version.major < 3
|
|
|
|
&& dst_param.reg.type == WINED3DSPR_TEXCRDOUT)
|
2008-12-15 12:10:14 +01:00
|
|
|
{
|
2009-06-30 10:58:14 +02:00
|
|
|
reg_maps->texcoord_mask[dst_param.reg.idx] |= dst_param.write_mask;
|
2007-12-06 22:10:11 +01:00
|
|
|
}
|
2009-06-30 10:58:15 +02:00
|
|
|
|
2009-07-09 22:24:27 +02:00
|
|
|
if (shader_version.type == WINED3D_SHADER_TYPE_PIXEL)
|
2009-04-28 09:53:28 +02:00
|
|
|
{
|
2009-07-09 22:24:27 +02:00
|
|
|
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *)This;
|
|
|
|
|
|
|
|
if(dst_param.reg.type == WINED3DSPR_COLOROUT && dst_param.reg.idx == 0)
|
|
|
|
{
|
2009-06-30 10:58:15 +02:00
|
|
|
/* Many 2.0 and 3.0 pixel shaders end with a MOV from a temp register to
|
|
|
|
* COLOROUT 0. If we know this in advance, the ARB shader backend can skip
|
|
|
|
* the mov and perform the sRGB write correction from the source register.
|
|
|
|
*
|
|
|
|
* However, if the mov is only partial, we can't do this, and if the write
|
|
|
|
* comes from an instruction other than MOV it is hard to do as well. If
|
|
|
|
* COLOROUT 0 is overwritten partially later, the marker is dropped again. */
|
|
|
|
|
2009-07-09 22:24:27 +02:00
|
|
|
ps->color0_mov = FALSE;
|
|
|
|
if (ins.handler_idx == WINED3DSIH_MOV)
|
|
|
|
{
|
|
|
|
/* Used later when the source register is read. */
|
|
|
|
color0_mov = TRUE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* Also drop the MOV marker if the source register is overwritten prior to the shader
|
|
|
|
* end
|
|
|
|
*/
|
|
|
|
else if(dst_param.reg.type == WINED3DSPR_TEMP && dst_param.reg.idx == ps->color0_reg)
|
2009-05-26 15:53:52 +02:00
|
|
|
{
|
2009-07-09 22:24:27 +02:00
|
|
|
ps->color0_mov = FALSE;
|
2009-05-26 15:53:52 +02:00
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
}
|
2009-05-04 09:49:27 +02:00
|
|
|
|
|
|
|
/* Declare 1.X samplers implicitly, based on the destination reg. number */
|
2009-05-06 17:59:21 +02:00
|
|
|
if (shader_version.major == 1
|
2009-05-04 09:49:27 +02:00
|
|
|
&& (ins.handler_idx == WINED3DSIH_TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEM
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEML
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXDP3TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x2TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3SPEC
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3TEX
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXM3x3VSPEC
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2AR
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2GB
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXREG2RGB))
|
|
|
|
{
|
|
|
|
/* Fake sampler usage, only set reserved bit and ttype */
|
2009-05-07 16:36:07 +02:00
|
|
|
DWORD sampler_code = dst_param.reg.idx;
|
2009-05-04 09:49:27 +02:00
|
|
|
|
|
|
|
TRACE("Setting fake 2D sampler for 1.x pixelshader\n");
|
|
|
|
reg_maps->sampler_type[sampler_code] = WINED3DSTT_2D;
|
|
|
|
|
|
|
|
/* texbem is only valid with < 1.4 pixel shaders */
|
|
|
|
if (ins.handler_idx == WINED3DSIH_TEXBEM
|
|
|
|
|| ins.handler_idx == WINED3DSIH_TEXBEML)
|
|
|
|
{
|
2009-08-12 09:44:25 +02:00
|
|
|
reg_maps->bumpmat |= 1 << dst_param.reg.idx;
|
2009-05-04 09:49:27 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TEXBEML)
|
|
|
|
{
|
2009-08-12 09:44:26 +02:00
|
|
|
reg_maps->luminanceparams |= 1 << dst_param.reg.idx;
|
2009-05-04 09:49:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-06-30 10:58:13 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_BEM)
|
2009-05-04 09:49:27 +02:00
|
|
|
{
|
2009-08-12 09:44:25 +02:00
|
|
|
reg_maps->bumpmat |= 1 << dst_param.reg.idx;
|
2009-05-04 09:49:27 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ins.handler_idx == WINED3DSIH_NRM)
|
|
|
|
{
|
|
|
|
reg_maps->usesnrm = 1;
|
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DSY)
|
|
|
|
{
|
|
|
|
reg_maps->usesdsy = 1;
|
2007-09-05 20:09:06 +02:00
|
|
|
}
|
2009-05-29 17:11:04 +02:00
|
|
|
else if (ins.handler_idx == WINED3DSIH_DSX)
|
|
|
|
{
|
|
|
|
reg_maps->usesdsx = 1;
|
|
|
|
}
|
2009-05-03 20:38:09 +02:00
|
|
|
else if(ins.handler_idx == WINED3DSIH_TEXLDD)
|
|
|
|
{
|
|
|
|
reg_maps->usestexldd = 1;
|
|
|
|
}
|
2009-05-29 17:24:55 +02:00
|
|
|
else if(ins.handler_idx == WINED3DSIH_TEXLDL)
|
|
|
|
{
|
|
|
|
reg_maps->usestexldl = 1;
|
|
|
|
}
|
2009-05-07 19:12:07 +02:00
|
|
|
else if(ins.handler_idx == WINED3DSIH_MOVA)
|
|
|
|
{
|
|
|
|
reg_maps->usesmova = 1;
|
|
|
|
}
|
2009-06-25 14:44:00 +02:00
|
|
|
else if(ins.handler_idx == WINED3DSIH_IFC)
|
|
|
|
{
|
|
|
|
reg_maps->usesifc = 1;
|
|
|
|
}
|
2009-06-25 18:54:28 +02:00
|
|
|
else if(ins.handler_idx == WINED3DSIH_CALL)
|
|
|
|
{
|
|
|
|
reg_maps->usescall = 1;
|
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
|
|
|
|
limit = ins.src_count + (ins.predicate ? 1 : 0);
|
|
|
|
for (i = 0; i < limit; ++i)
|
|
|
|
{
|
|
|
|
struct wined3d_shader_src_param src_param, src_rel_addr;
|
2009-05-11 16:43:49 +02:00
|
|
|
unsigned int count;
|
2009-04-28 09:53:28 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
|
2009-05-11 16:43:49 +02:00
|
|
|
count = get_instr_extra_regcount(ins.handler_idx, i);
|
|
|
|
|
2009-06-30 12:18:26 +02:00
|
|
|
shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
|
2009-05-11 16:43:49 +02:00
|
|
|
while (count)
|
2009-05-07 17:31:20 +02:00
|
|
|
{
|
2009-05-11 16:43:49 +02:00
|
|
|
++src_param.reg.idx;
|
2009-06-30 12:18:26 +02:00
|
|
|
shader_record_register_usage(This, reg_maps, &src_param.reg, shader_version.type);
|
2009-05-11 16:43:49 +02:00
|
|
|
--count;
|
2009-05-07 17:31:20 +02:00
|
|
|
}
|
2009-05-26 15:53:52 +02:00
|
|
|
|
|
|
|
if(color0_mov)
|
|
|
|
{
|
|
|
|
IWineD3DPixelShaderImpl *ps = (IWineD3DPixelShaderImpl *) This;
|
|
|
|
if(src_param.reg.type == WINED3DSPR_TEMP &&
|
|
|
|
src_param.swizzle == WINED3DSP_NOSWIZZLE)
|
|
|
|
{
|
|
|
|
ps->color0_mov = TRUE;
|
|
|
|
ps->color0_reg = src_param.reg.idx;
|
|
|
|
}
|
|
|
|
}
|
2009-04-28 09:53:28 +02:00
|
|
|
}
|
2006-05-10 00:03:09 +02:00
|
|
|
}
|
|
|
|
}
|
2007-09-14 13:21:52 +02:00
|
|
|
reg_maps->loop_depth = max_loop_depth;
|
2006-07-10 06:51:03 +02:00
|
|
|
|
2009-07-09 09:56:11 +02:00
|
|
|
This->baseShader.functionLength = ((const char *)pToken - (const char *)byte_code);
|
2008-12-11 11:52:37 +01:00
|
|
|
|
2006-07-10 06:51:03 +02:00
|
|
|
return WINED3D_OK;
|
2006-05-10 00:03:09 +02:00
|
|
|
}
|
|
|
|
|
2009-08-17 09:39:09 +02:00
|
|
|
unsigned int shader_find_free_input_register(const struct shader_reg_maps *reg_maps, unsigned int max)
|
|
|
|
{
|
|
|
|
DWORD map = 1 << max;
|
|
|
|
map |= map - 1;
|
|
|
|
map &= reg_maps->shader_version.major < 3 ? ~reg_maps->texcoord : ~reg_maps->input_registers;
|
|
|
|
|
|
|
|
return wined3d_log2i(map);
|
|
|
|
}
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
static void shader_dump_decl_usage(const struct wined3d_shader_semantic *semantic,
|
|
|
|
const struct wined3d_shader_version *shader_version)
|
2008-12-04 17:41:31 +01:00
|
|
|
{
|
2006-07-03 08:03:47 +02:00
|
|
|
TRACE("dcl");
|
2006-05-10 04:26:05 +02:00
|
|
|
|
2009-05-07 16:36:07 +02:00
|
|
|
if (semantic->reg.reg.type == WINED3DSPR_SAMPLER)
|
2009-04-30 11:02:20 +02:00
|
|
|
{
|
|
|
|
switch (semantic->sampler_type)
|
|
|
|
{
|
2006-07-28 21:34:39 +02:00
|
|
|
case WINED3DSTT_2D: TRACE("_2d"); break;
|
|
|
|
case WINED3DSTT_CUBE: TRACE("_cube"); break;
|
|
|
|
case WINED3DSTT_VOLUME: TRACE("_volume"); break;
|
2009-04-30 11:02:20 +02:00
|
|
|
default: TRACE("_unknown_ttype(0x%08x)", semantic->sampler_type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2006-07-03 08:03:47 +02:00
|
|
|
/* Pixel shaders 3.0 don't have usage semantics */
|
2009-07-07 11:08:04 +02:00
|
|
|
if (shader_version->major < 3 && shader_version->type == WINED3D_SHADER_TYPE_PIXEL)
|
2006-07-03 08:03:47 +02:00
|
|
|
return;
|
|
|
|
else
|
|
|
|
TRACE("_");
|
|
|
|
|
2009-04-30 11:02:20 +02:00
|
|
|
switch (semantic->usage)
|
|
|
|
{
|
|
|
|
case WINED3DDECLUSAGE_POSITION:
|
|
|
|
TRACE("position%d", semantic->usage_idx);
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_BLENDINDICES:
|
|
|
|
TRACE("blend");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_BLENDWEIGHT:
|
|
|
|
TRACE("weight");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_NORMAL:
|
|
|
|
TRACE("normal%d", semantic->usage_idx);
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_PSIZE:
|
|
|
|
TRACE("psize");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_COLOR:
|
|
|
|
if (semantic->usage_idx == 0) TRACE("color");
|
|
|
|
else TRACE("specular%d", (semantic->usage_idx - 1));
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_TEXCOORD:
|
|
|
|
TRACE("texture%d", semantic->usage_idx);
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_TANGENT:
|
|
|
|
TRACE("tangent");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_BINORMAL:
|
|
|
|
TRACE("binormal");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_TESSFACTOR:
|
|
|
|
TRACE("tessfactor");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_POSITIONT:
|
|
|
|
TRACE("positionT%d", semantic->usage_idx);
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_FOG:
|
|
|
|
TRACE("fog");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_DEPTH:
|
|
|
|
TRACE("depth");
|
|
|
|
break;
|
|
|
|
case WINED3DDECLUSAGE_SAMPLE:
|
|
|
|
TRACE("sample");
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
FIXME("unknown_semantics(0x%08x)", semantic->usage);
|
2006-05-10 04:26:05 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
static void shader_dump_register(const struct wined3d_shader_register *reg,
|
|
|
|
const struct wined3d_shader_version *shader_version)
|
2008-12-02 18:41:33 +01:00
|
|
|
{
|
2009-04-30 11:02:20 +02:00
|
|
|
static const char * const rastout_reg_names[] = {"oPos", "oFog", "oPts"};
|
|
|
|
static const char * const misctype_reg_names[] = {"vPos", "vFace"};
|
2009-05-11 16:43:49 +02:00
|
|
|
UINT offset = reg->idx;
|
2006-05-14 15:43:31 +02:00
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
switch (reg->type)
|
2009-04-30 11:02:19 +02:00
|
|
|
{
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_TEMP:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("r");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_INPUT:
|
2006-06-06 08:40:08 +02:00
|
|
|
TRACE("v");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_CONST:
|
|
|
|
case WINED3DSPR_CONST2:
|
|
|
|
case WINED3DSPR_CONST3:
|
|
|
|
case WINED3DSPR_CONST4:
|
2006-05-17 08:05:49 +02:00
|
|
|
TRACE("c");
|
2009-05-11 16:43:49 +02:00
|
|
|
offset = shader_get_float_offset(reg->type, reg->idx);
|
2009-04-30 11:02:19 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2009-04-30 11:02:19 +02:00
|
|
|
case WINED3DSPR_TEXTURE: /* vs: case WINED3DSPR_ADDR */
|
2009-07-07 11:08:04 +02:00
|
|
|
TRACE("%c", shader_version->type == WINED3D_SHADER_TYPE_PIXEL ? 't' : 'a');
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_RASTOUT:
|
2009-05-11 16:43:49 +02:00
|
|
|
TRACE("%s", rastout_reg_names[reg->idx]);
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_COLOROUT:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("oC");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_DEPTHOUT:
|
2006-05-14 15:43:31 +02:00
|
|
|
TRACE("oDepth");
|
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_ATTROUT:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("oD");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2006-05-18 03:08:29 +02:00
|
|
|
|
2009-04-30 11:02:20 +02:00
|
|
|
case WINED3DSPR_TEXCRDOUT:
|
2006-05-18 03:08:29 +02:00
|
|
|
/* Vertex shaders >= 3.0 use general purpose output registers
|
2006-10-10 01:45:55 +02:00
|
|
|
* (WINED3DSPR_OUTPUT), which can include an address token */
|
2009-05-06 17:59:21 +02:00
|
|
|
if (shader_version->major >= 3) TRACE("o");
|
2009-05-01 09:13:53 +02:00
|
|
|
else TRACE("oT");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_CONSTINT:
|
2006-05-17 08:05:49 +02:00
|
|
|
TRACE("i");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_CONSTBOOL:
|
2006-05-17 08:05:49 +02:00
|
|
|
TRACE("b");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_LABEL:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("l");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_LOOP:
|
2006-05-17 08:05:49 +02:00
|
|
|
TRACE("aL");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_SAMPLER:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("s");
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2007-05-03 21:01:09 +02:00
|
|
|
case WINED3DSPR_MISCTYPE:
|
2009-05-11 16:43:49 +02:00
|
|
|
if (reg->idx > 1) FIXME("Unhandled misctype register %d\n", reg->idx);
|
|
|
|
else TRACE("%s", misctype_reg_names[reg->idx]);
|
2007-05-03 21:01:09 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2006-10-10 01:45:55 +02:00
|
|
|
case WINED3DSPR_PREDICATE:
|
2009-05-01 09:13:53 +02:00
|
|
|
TRACE("p");
|
2006-05-18 03:08:29 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
|
2009-05-06 17:59:22 +02:00
|
|
|
case WINED3DSPR_IMMCONST:
|
|
|
|
TRACE("l");
|
|
|
|
break;
|
|
|
|
|
2009-07-16 13:08:22 +02:00
|
|
|
case WINED3DSPR_CONSTBUFFER:
|
|
|
|
TRACE("cb");
|
|
|
|
break;
|
|
|
|
|
2006-05-14 15:43:31 +02:00
|
|
|
default:
|
2009-05-11 16:43:49 +02:00
|
|
|
TRACE("unhandled_rtype(%#x)", reg->type);
|
2006-05-14 15:43:31 +02:00
|
|
|
break;
|
2009-04-30 11:02:20 +02:00
|
|
|
}
|
2009-05-01 09:13:53 +02:00
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
if (reg->type == WINED3DSPR_IMMCONST)
|
2009-05-06 17:59:22 +02:00
|
|
|
{
|
|
|
|
TRACE("(");
|
2009-05-11 16:43:49 +02:00
|
|
|
switch (reg->immconst_type)
|
2009-05-06 17:59:22 +02:00
|
|
|
{
|
|
|
|
case WINED3D_IMMCONST_FLOAT:
|
2009-07-09 09:56:11 +02:00
|
|
|
TRACE("%.8e", *(const float *)reg->immconst_data);
|
2009-05-06 17:59:22 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_IMMCONST_FLOAT4:
|
|
|
|
TRACE("%.8e, %.8e, %.8e, %.8e",
|
2009-07-09 09:56:11 +02:00
|
|
|
*(const float *)®->immconst_data[0], *(const float *)®->immconst_data[1],
|
|
|
|
*(const float *)®->immconst_data[2], *(const float *)®->immconst_data[3]);
|
2009-05-06 17:59:22 +02:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
2009-05-11 16:43:49 +02:00
|
|
|
TRACE("<unhandled immconst_type %#x>", reg->immconst_type);
|
2009-05-06 17:59:22 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
TRACE(")");
|
|
|
|
}
|
2009-05-11 16:43:49 +02:00
|
|
|
else if (reg->type != WINED3DSPR_RASTOUT && reg->type != WINED3DSPR_MISCTYPE)
|
2009-05-01 09:13:53 +02:00
|
|
|
{
|
2009-07-16 13:08:21 +02:00
|
|
|
if (reg->array_idx != ~0U)
|
2009-05-01 09:13:53 +02:00
|
|
|
{
|
2009-07-16 13:08:21 +02:00
|
|
|
TRACE("%u[%u", offset, reg->array_idx);
|
|
|
|
if (reg->rel_addr)
|
|
|
|
{
|
|
|
|
TRACE(" + ");
|
|
|
|
shader_dump_src_param(reg->rel_addr, shader_version);
|
|
|
|
}
|
|
|
|
TRACE("]");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (reg->rel_addr)
|
|
|
|
{
|
|
|
|
TRACE("[");
|
|
|
|
shader_dump_src_param(reg->rel_addr, shader_version);
|
|
|
|
TRACE(" + ");
|
|
|
|
}
|
|
|
|
TRACE("%u", offset);
|
|
|
|
if (reg->rel_addr) TRACE("]");
|
2009-05-01 09:13:53 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-30 11:02:20 +02:00
|
|
|
}
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
void shader_dump_dst_param(const struct wined3d_shader_dst_param *param,
|
|
|
|
const struct wined3d_shader_version *shader_version)
|
2009-04-30 11:02:20 +02:00
|
|
|
{
|
|
|
|
DWORD write_mask = param->write_mask;
|
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
shader_dump_register(¶m->reg, shader_version);
|
2009-04-30 11:02:20 +02:00
|
|
|
|
|
|
|
if (write_mask != WINED3DSP_WRITEMASK_ALL)
|
|
|
|
{
|
|
|
|
static const char *write_mask_chars = "xyzw";
|
|
|
|
|
|
|
|
TRACE(".");
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_0) TRACE("%c", write_mask_chars[0]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_1) TRACE("%c", write_mask_chars[1]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_2) TRACE("%c", write_mask_chars[2]);
|
|
|
|
if (write_mask & WINED3DSP_WRITEMASK_3) TRACE("%c", write_mask_chars[3]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
void shader_dump_src_param(const struct wined3d_shader_src_param *param,
|
|
|
|
const struct wined3d_shader_version *shader_version)
|
2009-04-30 11:02:20 +02:00
|
|
|
{
|
|
|
|
DWORD src_modifier = param->modifiers;
|
|
|
|
DWORD swizzle = param->swizzle;
|
|
|
|
|
|
|
|
if (src_modifier == WINED3DSPSM_NEG
|
|
|
|
|| src_modifier == WINED3DSPSM_BIASNEG
|
|
|
|
|| src_modifier == WINED3DSPSM_SIGNNEG
|
|
|
|
|| src_modifier == WINED3DSPSM_X2NEG
|
|
|
|
|| src_modifier == WINED3DSPSM_ABSNEG)
|
|
|
|
TRACE("-");
|
|
|
|
else if (src_modifier == WINED3DSPSM_COMP)
|
|
|
|
TRACE("1-");
|
|
|
|
else if (src_modifier == WINED3DSPSM_NOT)
|
|
|
|
TRACE("!");
|
|
|
|
|
|
|
|
if (src_modifier == WINED3DSPSM_ABS || src_modifier == WINED3DSPSM_ABSNEG)
|
|
|
|
TRACE("abs(");
|
|
|
|
|
2009-05-11 16:43:49 +02:00
|
|
|
shader_dump_register(¶m->reg, shader_version);
|
2009-04-30 11:02:20 +02:00
|
|
|
|
|
|
|
if (src_modifier)
|
|
|
|
{
|
|
|
|
switch (src_modifier)
|
2009-04-30 11:02:19 +02:00
|
|
|
{
|
2009-04-30 11:02:20 +02:00
|
|
|
case WINED3DSPSM_NONE: break;
|
|
|
|
case WINED3DSPSM_NEG: break;
|
|
|
|
case WINED3DSPSM_NOT: break;
|
|
|
|
case WINED3DSPSM_BIAS: TRACE("_bias"); break;
|
|
|
|
case WINED3DSPSM_BIASNEG: TRACE("_bias"); break;
|
|
|
|
case WINED3DSPSM_SIGN: TRACE("_bx2"); break;
|
|
|
|
case WINED3DSPSM_SIGNNEG: TRACE("_bx2"); break;
|
|
|
|
case WINED3DSPSM_COMP: break;
|
|
|
|
case WINED3DSPSM_X2: TRACE("_x2"); break;
|
|
|
|
case WINED3DSPSM_X2NEG: TRACE("_x2"); break;
|
|
|
|
case WINED3DSPSM_DZ: TRACE("_dz"); break;
|
|
|
|
case WINED3DSPSM_DW: TRACE("_dw"); break;
|
|
|
|
case WINED3DSPSM_ABSNEG: TRACE(")"); break;
|
|
|
|
case WINED3DSPSM_ABS: TRACE(")"); break;
|
|
|
|
default:
|
|
|
|
TRACE("_unknown_modifier(%#x)", src_modifier);
|
2006-05-14 15:43:31 +02:00
|
|
|
}
|
2009-04-30 11:02:20 +02:00
|
|
|
}
|
2006-05-14 15:43:31 +02:00
|
|
|
|
2009-04-30 11:02:20 +02:00
|
|
|
if (swizzle != WINED3DSP_NOSWIZZLE)
|
|
|
|
{
|
|
|
|
static const char *swizzle_chars = "xyzw";
|
|
|
|
DWORD swizzle_x = swizzle & 0x03;
|
|
|
|
DWORD swizzle_y = (swizzle >> 2) & 0x03;
|
|
|
|
DWORD swizzle_z = (swizzle >> 4) & 0x03;
|
|
|
|
DWORD swizzle_w = (swizzle >> 6) & 0x03;
|
|
|
|
|
|
|
|
if (swizzle_x == swizzle_y
|
|
|
|
&& swizzle_x == swizzle_z
|
|
|
|
&& swizzle_x == swizzle_w)
|
2009-04-22 10:48:34 +02:00
|
|
|
{
|
2009-04-30 11:02:20 +02:00
|
|
|
TRACE(".%c", swizzle_chars[swizzle_x]);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
TRACE(".%c%c%c%c", swizzle_chars[swizzle_x], swizzle_chars[swizzle_y],
|
|
|
|
swizzle_chars[swizzle_z], swizzle_chars[swizzle_w]);
|
2006-05-14 15:43:31 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Shared code in order to generate the bulk of the shader string.
|
|
|
|
* NOTE: A description of how to parse tokens can be found on msdn */
|
2009-07-09 09:56:08 +02:00
|
|
|
void shader_generate_main(IWineD3DBaseShader *iface, struct wined3d_shader_buffer *buffer,
|
2009-05-15 13:56:40 +02:00
|
|
|
const shader_reg_maps *reg_maps, const DWORD *pFunction, void *backend_ctx)
|
2008-11-25 14:36:09 +01:00
|
|
|
{
|
2006-05-10 04:32:34 +02:00
|
|
|
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
|
2007-09-21 23:53:57 +02:00
|
|
|
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
|
2009-05-05 09:38:03 +02:00
|
|
|
const struct wined3d_shader_frontend *fe = This->baseShader.frontend;
|
|
|
|
void *fe_data = This->baseShader.frontend_data;
|
2009-04-17 09:46:56 +02:00
|
|
|
struct wined3d_shader_src_param src_rel_addr[4];
|
2009-04-15 10:06:28 +02:00
|
|
|
struct wined3d_shader_src_param src_param[4];
|
2009-05-06 17:59:21 +02:00
|
|
|
struct wined3d_shader_version shader_version;
|
2009-04-17 09:46:56 +02:00
|
|
|
struct wined3d_shader_src_param dst_rel_addr;
|
2009-04-03 10:36:38 +02:00
|
|
|
struct wined3d_shader_dst_param dst_param;
|
2009-04-01 12:23:01 +02:00
|
|
|
struct wined3d_shader_instruction ins;
|
2009-04-15 10:06:28 +02:00
|
|
|
struct wined3d_shader_context ctx;
|
2006-05-10 04:32:34 +02:00
|
|
|
const DWORD *pToken = pFunction;
|
|
|
|
DWORD i;
|
2006-06-09 09:33:33 +02:00
|
|
|
|
2006-05-10 04:32:34 +02:00
|
|
|
/* Initialize current parsing state */
|
2009-04-15 10:06:28 +02:00
|
|
|
ctx.shader = iface;
|
|
|
|
ctx.reg_maps = reg_maps;
|
|
|
|
ctx.buffer = buffer;
|
2009-05-15 13:56:40 +02:00
|
|
|
ctx.backend_data = backend_ctx;
|
2009-04-15 10:06:28 +02:00
|
|
|
|
|
|
|
ins.ctx = &ctx;
|
2009-04-03 10:36:38 +02:00
|
|
|
ins.dst = &dst_param;
|
2009-04-15 10:06:28 +02:00
|
|
|
ins.src = src_param;
|
2006-05-10 04:32:34 +02:00
|
|
|
This->baseShader.parse_state.current_row = 0;
|
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
fe->shader_read_header(fe_data, &pToken, &shader_version);
|
2009-04-24 09:17:58 +02:00
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
while (!fe->shader_is_end(fe_data, &pToken))
|
2008-12-15 12:10:15 +01:00
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
const char *comment;
|
2009-04-24 09:17:58 +02:00
|
|
|
UINT param_size;
|
2009-04-01 12:23:00 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Skip comment tokens */
|
2009-05-04 09:49:27 +02:00
|
|
|
fe->shader_read_comment(&pToken, &comment);
|
2009-05-01 09:13:54 +02:00
|
|
|
if (comment) continue;
|
2006-05-10 04:32:34 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Read opcode */
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size);
|
2006-05-17 08:04:30 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Unknown opcode and its parameters */
|
2009-04-24 09:17:58 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
2008-12-15 12:10:15 +01:00
|
|
|
{
|
2009-04-24 09:17:58 +02:00
|
|
|
TRACE("Skipping unrecognized instruction.\n");
|
|
|
|
pToken += param_size;
|
2008-12-15 12:10:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
2006-05-10 04:32:34 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Nothing to do */
|
2009-04-24 09:17:58 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_DCL
|
|
|
|
|| ins.handler_idx == WINED3DSIH_NOP
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DEF
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DEFI
|
|
|
|
|| ins.handler_idx == WINED3DSIH_DEFB
|
2009-06-25 18:54:28 +02:00
|
|
|
|| ins.handler_idx == WINED3DSIH_PHASE)
|
2008-12-15 12:10:15 +01:00
|
|
|
{
|
2009-04-24 09:17:58 +02:00
|
|
|
pToken += param_size;
|
2008-12-15 12:10:15 +01:00
|
|
|
continue;
|
|
|
|
}
|
2006-05-17 08:04:30 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Destination token */
|
2009-05-06 17:59:21 +02:00
|
|
|
if (ins.dst_count) fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
|
2006-05-10 04:47:35 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Predication token */
|
2009-04-24 09:17:58 +02:00
|
|
|
if (ins.predicate) ins.predicate = *pToken++;
|
2007-09-21 23:53:57 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Other source tokens */
|
2009-04-02 10:41:00 +02:00
|
|
|
for (i = 0; i < ins.src_count; ++i)
|
2008-12-15 12:10:15 +01:00
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src_param[i], &src_rel_addr[i]);
|
2008-12-15 12:10:15 +01:00
|
|
|
}
|
2006-06-14 04:32:14 +02:00
|
|
|
|
2008-12-15 12:10:15 +01:00
|
|
|
/* Call appropriate function for output target */
|
2009-05-27 18:23:16 +02:00
|
|
|
device->shader_backend->shader_handle_instruction(&ins);
|
2006-05-10 04:32:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-30 11:02:20 +02:00
|
|
|
static void shader_dump_ins_modifiers(const struct wined3d_shader_dst_param *dst)
|
2008-12-02 18:41:33 +01:00
|
|
|
{
|
2009-04-30 11:02:20 +02:00
|
|
|
DWORD mmask = dst->modifiers;
|
2006-05-10 19:53:07 +02:00
|
|
|
|
2009-04-30 11:02:20 +02:00
|
|
|
switch (dst->shift)
|
|
|
|
{
|
2006-05-10 19:53:07 +02:00
|
|
|
case 0: break;
|
|
|
|
case 13: TRACE("_d8"); break;
|
|
|
|
case 14: TRACE("_d4"); break;
|
|
|
|
case 15: TRACE("_d2"); break;
|
|
|
|
case 1: TRACE("_x2"); break;
|
|
|
|
case 2: TRACE("_x4"); break;
|
|
|
|
case 3: TRACE("_x8"); break;
|
2009-04-30 11:02:20 +02:00
|
|
|
default: TRACE("_unhandled_shift(%d)", dst->shift); break;
|
2006-05-10 19:53:07 +02:00
|
|
|
}
|
|
|
|
|
2006-10-10 01:48:12 +02:00
|
|
|
if (mmask & WINED3DSPDM_SATURATE) TRACE("_sat");
|
|
|
|
if (mmask & WINED3DSPDM_PARTIALPRECISION) TRACE("_pp");
|
|
|
|
if (mmask & WINED3DSPDM_MSAMPCENTROID) TRACE("_centroid");
|
2006-05-17 07:58:19 +02:00
|
|
|
|
2006-10-10 01:48:12 +02:00
|
|
|
mmask &= ~(WINED3DSPDM_SATURATE | WINED3DSPDM_PARTIALPRECISION | WINED3DSPDM_MSAMPCENTROID);
|
2006-05-17 07:58:19 +02:00
|
|
|
if (mmask)
|
2009-04-23 09:24:26 +02:00
|
|
|
FIXME("_unrecognized_modifier(%#x)", mmask);
|
2006-05-10 19:53:07 +02:00
|
|
|
}
|
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
void shader_trace_init(const struct wined3d_shader_frontend *fe, void *fe_data, const DWORD *pFunction)
|
2008-12-11 11:52:37 +01:00
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
struct wined3d_shader_version shader_version;
|
2006-06-12 08:54:30 +02:00
|
|
|
const DWORD* pToken = pFunction;
|
2009-07-01 09:46:16 +02:00
|
|
|
const char *type_prefix;
|
2006-06-12 08:54:30 +02:00
|
|
|
DWORD i;
|
|
|
|
|
2008-12-11 11:52:37 +01:00
|
|
|
TRACE("Parsing %p\n", pFunction);
|
2006-06-12 08:54:30 +02:00
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
fe->shader_read_header(fe_data, &pToken, &shader_version);
|
2009-05-05 09:38:03 +02:00
|
|
|
|
2009-07-01 09:46:16 +02:00
|
|
|
switch (shader_version.type)
|
|
|
|
{
|
|
|
|
case WINED3D_SHADER_TYPE_VERTEX:
|
|
|
|
type_prefix = "vs";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_TYPE_GEOMETRY:
|
|
|
|
type_prefix = "gs";
|
|
|
|
break;
|
|
|
|
|
|
|
|
case WINED3D_SHADER_TYPE_PIXEL:
|
|
|
|
type_prefix = "ps";
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
FIXME("Unhandled shader type %#x.\n", shader_version.type);
|
|
|
|
type_prefix = "unknown";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("%s_%u_%u\n", type_prefix, shader_version.major, shader_version.minor);
|
2008-12-11 11:52:37 +01:00
|
|
|
|
2009-05-05 09:38:03 +02:00
|
|
|
while (!fe->shader_is_end(fe_data, &pToken))
|
2008-12-08 10:30:02 +01:00
|
|
|
{
|
2009-04-27 09:37:14 +02:00
|
|
|
struct wined3d_shader_instruction ins;
|
2009-05-01 09:13:54 +02:00
|
|
|
const char *comment;
|
2009-04-27 09:37:14 +02:00
|
|
|
UINT param_size;
|
|
|
|
|
2009-05-01 09:13:54 +02:00
|
|
|
/* comment */
|
2009-05-04 09:49:27 +02:00
|
|
|
fe->shader_read_comment(&pToken, &comment);
|
2009-05-01 09:13:54 +02:00
|
|
|
if (comment)
|
2008-12-08 10:30:02 +01:00
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
TRACE("//%s\n", comment);
|
2008-12-08 10:30:02 +01:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_opcode(fe_data, &pToken, &ins, ¶m_size);
|
2009-04-27 09:37:14 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_TABLE_SIZE)
|
2008-12-08 10:30:02 +01:00
|
|
|
{
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE("Skipping unrecognized instruction.\n");
|
|
|
|
pToken += param_size;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ins.handler_idx == WINED3DSIH_DCL)
|
|
|
|
{
|
2009-04-30 11:02:20 +02:00
|
|
|
struct wined3d_shader_semantic semantic;
|
2009-04-27 09:37:14 +02:00
|
|
|
|
2009-05-04 09:49:27 +02:00
|
|
|
fe->shader_read_semantic(&pToken, &semantic);
|
2009-04-30 11:02:19 +02:00
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
shader_dump_decl_usage(&semantic, &shader_version);
|
2009-04-30 11:02:20 +02:00
|
|
|
shader_dump_ins_modifiers(&semantic.reg);
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE(" ");
|
2009-05-06 17:59:21 +02:00
|
|
|
shader_dump_dst_param(&semantic.reg, &shader_version);
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEF)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-04-27 09:37:14 +02:00
|
|
|
|
2009-05-07 16:36:07 +02:00
|
|
|
TRACE("def c%u = %f, %f, %f, %f", shader_get_float_offset(dst.reg.type, dst.reg.idx),
|
2009-05-01 09:13:54 +02:00
|
|
|
*(const float *)(pToken),
|
2009-04-27 09:37:14 +02:00
|
|
|
*(const float *)(pToken + 1),
|
|
|
|
*(const float *)(pToken + 2),
|
2009-05-01 09:13:54 +02:00
|
|
|
*(const float *)(pToken + 3));
|
|
|
|
pToken += 4;
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFI)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-05-01 09:13:54 +02:00
|
|
|
|
2009-05-07 16:36:07 +02:00
|
|
|
TRACE("defi i%u = %d, %d, %d, %d", dst.reg.idx,
|
2009-05-01 09:13:54 +02:00
|
|
|
*(pToken),
|
2009-04-27 09:37:14 +02:00
|
|
|
*(pToken + 1),
|
|
|
|
*(pToken + 2),
|
2009-05-01 09:13:54 +02:00
|
|
|
*(pToken + 3));
|
|
|
|
pToken += 4;
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_DEFB)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_dst_param dst;
|
|
|
|
struct wined3d_shader_src_param rel_addr;
|
|
|
|
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst, &rel_addr);
|
2009-05-01 09:13:54 +02:00
|
|
|
|
2009-05-07 16:36:07 +02:00
|
|
|
TRACE("defb b%u = %s", dst.reg.idx, *pToken ? "true" : "false");
|
2009-05-01 09:13:54 +02:00
|
|
|
++pToken;
|
2008-12-08 10:30:02 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
struct wined3d_shader_src_param dst_rel_addr, src_rel_addr;
|
|
|
|
struct wined3d_shader_dst_param dst_param;
|
|
|
|
struct wined3d_shader_src_param src_param;
|
|
|
|
|
|
|
|
if (ins.dst_count)
|
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_dst_param(fe_data, &pToken, &dst_param, &dst_rel_addr);
|
2009-05-01 09:13:54 +02:00
|
|
|
}
|
2008-12-08 10:30:02 +01:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
/* Print out predication source token first - it follows
|
|
|
|
* the destination token. */
|
|
|
|
if (ins.predicate)
|
2008-12-08 10:30:02 +01:00
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE("(");
|
2009-05-06 17:59:21 +02:00
|
|
|
shader_dump_src_param(&src_param, &shader_version);
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE(") ");
|
2008-12-08 10:30:02 +01:00
|
|
|
}
|
2006-06-12 08:54:30 +02:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
/* PixWin marks instructions with the coissue flag with a '+' */
|
|
|
|
if (ins.coissue) TRACE("+");
|
2008-12-08 10:30:02 +01:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE("%s", shader_opcode_names[ins.handler_idx]);
|
2008-12-08 10:30:02 +01:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
if (ins.handler_idx == WINED3DSIH_IFC
|
|
|
|
|| ins.handler_idx == WINED3DSIH_BREAKC)
|
|
|
|
{
|
|
|
|
switch (ins.flags)
|
2008-12-08 10:30:02 +01:00
|
|
|
{
|
2009-04-27 09:37:14 +02:00
|
|
|
case COMPARISON_GT: TRACE("_gt"); break;
|
|
|
|
case COMPARISON_EQ: TRACE("_eq"); break;
|
|
|
|
case COMPARISON_GE: TRACE("_ge"); break;
|
|
|
|
case COMPARISON_LT: TRACE("_lt"); break;
|
|
|
|
case COMPARISON_NE: TRACE("_ne"); break;
|
|
|
|
case COMPARISON_LE: TRACE("_le"); break;
|
|
|
|
default: TRACE("_(%u)", ins.flags);
|
2008-12-08 10:30:02 +01:00
|
|
|
}
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
|
|
|
else if (ins.handler_idx == WINED3DSIH_TEX
|
2009-05-06 17:59:21 +02:00
|
|
|
&& shader_version.major >= 2
|
2009-04-27 09:37:14 +02:00
|
|
|
&& (ins.flags & WINED3DSI_TEXLD_PROJECT))
|
|
|
|
{
|
|
|
|
TRACE("p");
|
|
|
|
}
|
2006-06-12 12:57:04 +02:00
|
|
|
|
2009-05-01 09:13:54 +02:00
|
|
|
/* We already read the destination token, print it. */
|
2009-04-27 09:37:14 +02:00
|
|
|
if (ins.dst_count)
|
|
|
|
{
|
2009-05-01 09:13:54 +02:00
|
|
|
shader_dump_ins_modifiers(&dst_param);
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE(" ");
|
2009-05-06 17:59:21 +02:00
|
|
|
shader_dump_dst_param(&dst_param, &shader_version);
|
2009-04-27 09:37:14 +02:00
|
|
|
}
|
2006-06-12 12:57:04 +02:00
|
|
|
|
2009-04-27 09:37:14 +02:00
|
|
|
/* Other source tokens */
|
|
|
|
for (i = ins.dst_count; i < (ins.dst_count + ins.src_count); ++i)
|
|
|
|
{
|
2009-05-06 17:59:21 +02:00
|
|
|
fe->shader_read_src_param(fe_data, &pToken, &src_param, &src_rel_addr);
|
2009-04-30 11:02:19 +02:00
|
|
|
TRACE(!i ? " " : ", ");
|
2009-05-06 17:59:21 +02:00
|
|
|
shader_dump_src_param(&src_param, &shader_version);
|
2006-06-12 08:54:30 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-27 09:37:14 +02:00
|
|
|
TRACE("\n");
|
2006-06-12 08:54:30 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-12-09 09:52:39 +01:00
|
|
|
void shader_cleanup(IWineD3DBaseShader *iface)
|
|
|
|
{
|
|
|
|
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *)iface;
|
|
|
|
|
|
|
|
((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_destroy(iface);
|
2009-05-07 17:31:20 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->baseShader.reg_maps.constf);
|
2008-12-09 09:52:39 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, This->baseShader.function);
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsF);
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsB);
|
|
|
|
shader_delete_constant_list(&This->baseShader.constantsI);
|
|
|
|
list_remove(&This->baseShader.shader_list_entry);
|
2009-05-05 09:38:03 +02:00
|
|
|
|
|
|
|
if (This->baseShader.frontend && This->baseShader.frontend_data)
|
|
|
|
{
|
|
|
|
This->baseShader.frontend->shader_free(This->baseShader.frontend_data);
|
|
|
|
}
|
2008-12-09 09:52:39 +01:00
|
|
|
}
|
|
|
|
|
2009-05-27 18:23:16 +02:00
|
|
|
static void shader_none_handle_instruction(const struct wined3d_shader_instruction *ins) {}
|
2009-08-07 08:51:18 +02:00
|
|
|
static void shader_none_select(const struct wined3d_context *context, BOOL usePS, BOOL useVS) {}
|
2008-10-27 18:31:31 +01:00
|
|
|
static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types tex_type) {}
|
2008-07-10 17:57:35 +02:00
|
|
|
static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
|
2008-12-17 17:07:25 +01:00
|
|
|
static void shader_none_update_float_vertex_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
|
|
|
|
static void shader_none_update_float_pixel_constants(IWineD3DDevice *iface, UINT start, UINT count) {}
|
2009-08-06 08:12:20 +02:00
|
|
|
static void shader_none_load_constants(const struct wined3d_context *context, char usePS, char useVS) {}
|
2009-04-09 00:55:38 +02:00
|
|
|
static void shader_none_load_np2fixup_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
|
2007-11-20 17:40:54 +01:00
|
|
|
static void shader_none_destroy(IWineD3DBaseShader *iface) {}
|
2008-02-24 11:23:53 +01:00
|
|
|
static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
|
|
|
|
static void shader_none_free(IWineD3DDevice *iface) {}
|
2008-03-04 02:30:23 +01:00
|
|
|
static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
|
2006-11-27 20:50:37 +01:00
|
|
|
|
2009-07-17 10:34:01 +02:00
|
|
|
static void shader_none_get_caps(WINED3DDEVTYPE devtype,
|
|
|
|
const struct wined3d_gl_info *gl_info, struct shader_caps *pCaps)
|
2008-11-25 14:36:09 +01:00
|
|
|
{
|
2008-03-22 14:27:53 +01:00
|
|
|
/* Set the shader caps to 0 for the none shader backend */
|
|
|
|
pCaps->VertexShaderVersion = 0;
|
|
|
|
pCaps->PixelShaderVersion = 0;
|
2009-07-07 11:08:01 +02:00
|
|
|
pCaps->PixelShader1xMaxValue = 0.0f;
|
2008-03-18 19:39:26 +01:00
|
|
|
}
|
2009-10-29 10:37:09 +01:00
|
|
|
|
2008-12-03 14:53:43 +01:00
|
|
|
static BOOL shader_none_color_fixup_supported(struct color_fixup_desc fixup)
|
|
|
|
{
|
|
|
|
if (TRACE_ON(d3d_shader) && TRACE_ON(d3d))
|
|
|
|
{
|
|
|
|
TRACE("Checking support for fixup:\n");
|
|
|
|
dump_color_fixup_desc(fixup);
|
2008-08-07 21:51:35 +02:00
|
|
|
}
|
2008-12-03 14:53:43 +01:00
|
|
|
|
|
|
|
/* Faked to make some apps happy. */
|
|
|
|
if (!is_yuv_fixup(fixup))
|
|
|
|
{
|
|
|
|
TRACE("[OK]\n");
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("[FAILED]\n");
|
|
|
|
return FALSE;
|
2008-08-07 21:51:35 +02:00
|
|
|
}
|
2008-03-18 19:39:26 +01:00
|
|
|
|
2006-11-27 20:50:37 +01:00
|
|
|
const shader_backend_t none_shader_backend = {
|
2009-05-27 18:23:16 +02:00
|
|
|
shader_none_handle_instruction,
|
2008-07-06 14:00:52 +02:00
|
|
|
shader_none_select,
|
|
|
|
shader_none_select_depth_blt,
|
2008-07-10 17:57:35 +02:00
|
|
|
shader_none_deselect_depth_blt,
|
2008-12-17 17:07:25 +01:00
|
|
|
shader_none_update_float_vertex_constants,
|
|
|
|
shader_none_update_float_pixel_constants,
|
2008-07-06 14:00:52 +02:00
|
|
|
shader_none_load_constants,
|
2009-04-09 00:55:38 +02:00
|
|
|
shader_none_load_np2fixup_constants,
|
2008-07-06 14:00:52 +02:00
|
|
|
shader_none_destroy,
|
|
|
|
shader_none_alloc,
|
|
|
|
shader_none_free,
|
|
|
|
shader_none_dirty_const,
|
|
|
|
shader_none_get_caps,
|
2008-12-03 14:53:43 +01:00
|
|
|
shader_none_color_fixup_supported,
|
2006-11-27 20:50:37 +01:00
|
|
|
};
|