- sync wined3d with wine

svn path=/trunk/; revision=37957
This commit is contained in:
Kamil Hornicek
2008-12-09 12:16:19 +00:00
parent 185cda7129
commit 5fd8a2eae0
35 changed files with 10103 additions and 2854 deletions
File diff suppressed because it is too large Load Diff
@@ -26,6 +26,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
/* Some private defines, Constant associations, etc.
* Env bump matrix and per stage constant should be independent,
@@ -159,7 +160,9 @@ static const char *debug_rep(GLuint rep) {
}
#define GLINFO_LOCATION (*gl_info)
static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg) {
static GLuint register_for_arg(DWORD arg, const WineD3D_GL_Info *gl_info,
unsigned int stage, GLuint *mod, GLuint *rep, GLuint tmparg)
{
GLenum ret;
if(mod) *mod = GL_NONE;
@@ -224,7 +227,8 @@ static GLuint register_for_arg(DWORD arg, WineD3D_GL_Info *gl_info, unsigned int
return ret;
}
static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) {
static GLuint find_tmpreg(const struct texture_stage_op op[MAX_TEXTURES])
{
int lowest_read = -1;
int lowest_write = -1;
int i;
@@ -284,7 +288,8 @@ static GLuint find_tmpreg(struct texture_stage_op op[MAX_TEXTURES]) {
}
}
static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_GL_Info *gl_info) {
static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], const WineD3D_GL_Info *gl_info)
{
GLuint ret = GL_EXTCALL(glGenFragmentShadersATI(1));
unsigned int stage;
GLuint arg0, arg1, arg2, extrarg;
@@ -339,21 +344,30 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
/* Pass 2: Generate perturbation calculations */
for(stage = 0; stage < GL_LIMITS(textures); stage++) {
GLuint argmodextra_x, argmodextra_y;
struct color_fixup_desc fixup;
if(op[stage].cop == WINED3DTOP_DISABLE) break;
if(op[stage].cop != WINED3DTOP_BUMPENVMAP &&
op[stage].cop != WINED3DTOP_BUMPENVMAPLUMINANCE) continue;
/* Nice thing, we get the color correction for free :-) */
if(op[stage].color_correction == WINED3DFMT_V8U8) {
argmodextra = GL_2X_BIT_ATI | GL_BIAS_BIT_ATI;
} else {
argmodextra = 0;
if (fixup.x_source != CHANNEL_SOURCE_X || fixup.y_source != CHANNEL_SOURCE_Y)
{
FIXME("Swizzles not implemented\n");
argmodextra_x = GL_NONE;
argmodextra_y = GL_NONE;
}
else
{
/* Nice thing, we get the color correction for free :-) */
argmodextra_x = fixup.x_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
argmodextra_y = fixup.y_sign_fixup ? GL_2X_BIT_ATI | GL_BIAS_BIT_ATI : GL_NONE;
}
TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_RED_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, ATI_FFP_CONST_BUMPMAT(%d), GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_RED, GL_NONE)\n",
stage + 1, stage, debug_argmod(argmodextra), stage, stage + 1);
stage + 1, stage, debug_argmod(argmodextra_x), stage, stage + 1);
GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_RED_BIT_ATI, GL_NONE,
GL_REG_0_ATI + stage, GL_NONE, argmodextra,
GL_REG_0_ATI + stage, GL_NONE, argmodextra_x,
ATI_FFP_CONST_BUMPMAT(stage), GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage + 1, GL_RED, GL_NONE));
@@ -372,9 +386,9 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
GL_EXTCALL(glColorFragmentOp1ATI(GL_MOV_ATI, GL_REG_5_ATI, GL_GREEN_BIT_ATI, GL_NONE,
ATI_FFP_CONST_BUMPMAT(stage), GL_ALPHA, GL_NONE));
TRACE("glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_%d_ATI, GL_GREEN_BIT_ATI, GL_NONE, GL_REG_%d_ATI, GL_NONE, %s, GL_REG_5_ATI, GL_NONE, GL_NONE, GL_REG_%d_ATI, GL_GREEN, GL_NONE)\n",
stage + 1, stage, debug_argmod(argmodextra), stage + 1);
stage + 1, stage, debug_argmod(argmodextra_y), stage + 1);
GL_EXTCALL(glColorFragmentOp3ATI(GL_DOT2_ADD_ATI, GL_REG_0_ATI + stage + 1, GL_GREEN_BIT_ATI, GL_NONE,
GL_REG_0_ATI + stage, GL_NONE, argmodextra,
GL_REG_0_ATI + stage, GL_NONE, argmodextra_y,
GL_REG_5_ATI, GL_NONE, GL_2X_BIT_ATI | GL_BIAS_BIT_ATI,
GL_REG_0_ATI + stage + 1, GL_GREEN, GL_NONE));
}
@@ -802,30 +816,32 @@ static GLuint gen_ati_shader(struct texture_stage_op op[MAX_TEXTURES], WineD3D_G
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
IWineD3DDeviceImpl *This = stateblock->wineD3DDevice;
struct atifs_ffp_desc *desc;
const struct atifs_ffp_desc *desc;
struct ffp_frag_settings settings;
struct atifs_private_data *priv = (struct atifs_private_data *) This->fragment_priv;
DWORD mapped_stage;
unsigned int i;
gen_ffp_frag_op(stateblock, &settings, TRUE);
desc = (struct atifs_ffp_desc *) find_ffp_frag_shader(priv->fragment_shaders, &settings);
desc = (const struct atifs_ffp_desc *)find_ffp_frag_shader(priv->fragment_shaders, &settings);
if(!desc) {
desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*desc));
if(!desc) {
struct atifs_ffp_desc *new_desc = HeapAlloc(GetProcessHeap(), 0, sizeof(*new_desc));
if (!new_desc)
{
ERR("Out of memory\n");
return;
}
desc->num_textures_used = 0;
new_desc->num_textures_used = 0;
for(i = 0; i < GL_LIMITS(texture_stages); i++) {
if(settings.op[i].cop == WINED3DTOP_DISABLE) break;
desc->num_textures_used = i;
new_desc->num_textures_used = i;
}
memcpy(&desc->parent.settings, &settings, sizeof(settings));
desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
add_ffp_frag_shader(priv->fragment_shaders, &desc->parent);
TRACE("Allocated fixed function replacement shader descriptor %p\n", desc);
memcpy(&new_desc->parent.settings, &settings, sizeof(settings));
new_desc->shader = gen_ati_shader(settings.op, &GLINFO_LOCATION);
add_ffp_frag_shader(priv->fragment_shaders, &new_desc->parent);
TRACE("Allocated fixed function replacement shader descriptor %p\n", new_desc);
desc = new_desc;
}
/* GL_ATI_fragment_shader depends on the GL_TEXTURE_xD enable settings. Update the texture stages
@@ -1017,7 +1033,8 @@ static void atifs_enable(IWineD3DDevice *iface, BOOL enable) {
}
}
static void atifs_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps) {
static void atifs_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps)
{
caps->TextureOpCaps = WINED3DTEXOPCAPS_DISABLE |
WINED3DTEXOPCAPS_SELECTARG1 |
WINED3DTEXOPCAPS_SELECTARG2 |
@@ -1101,17 +1118,25 @@ static void atifs_free(IWineD3DDevice *iface) {
}
#undef GLINFO_LOCATION
static BOOL atifs_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s:", debug_d3dformat(fmt));
switch(fmt) {
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED\n");
return FALSE;
static BOOL atifs_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);
}
/* We only support sign fixup of the first two channels. */
if (fixup.x_source == CHANNEL_SOURCE_X && fixup.y_source == CHANNEL_SOURCE_Y
&& fixup.z_source == CHANNEL_SOURCE_Z && fixup.w_source == CHANNEL_SOURCE_W
&& !fixup.z_sign_fixup && !fixup.w_sign_fixup)
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
}
const struct fragment_pipeline atifs_fragment_pipeline = {
@@ -1119,7 +1144,7 @@ const struct fragment_pipeline atifs_fragment_pipeline = {
atifs_get_caps,
atifs_alloc,
atifs_free,
atifs_conv_supported,
atifs_color_fixup_supported,
atifs_fragmentstate_template,
TRUE /* We can disable projected textures */
};
+290 -232
View File
@@ -29,9 +29,12 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
#define GLNAME_REQUIRE_GLSL ((const char *)1)
static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version);
static inline BOOL shader_is_version_token(DWORD token) {
return shader_is_pshader_version(token) ||
shader_is_vshader_version(token);
@@ -73,45 +76,39 @@ int shader_addline(
return 0;
}
const SHADER_OPCODE* shader_get_opcode(
IWineD3DBaseShader *iface, const DWORD code) {
IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl*) iface;
const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *opcode_table, DWORD shader_version, DWORD code)
{
DWORD i = 0;
DWORD hex_version = This->baseShader.hex_version;
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
/** TODO: use dichotomic search */
while (NULL != shader_ins[i].name) {
if (((code & WINED3DSI_OPCODE_MASK) == shader_ins[i].opcode) &&
(((hex_version >= shader_ins[i].min_version) && (hex_version <= shader_ins[i].max_version)) ||
((shader_ins[i].min_version == 0) && (shader_ins[i].max_version == 0)))) {
return &shader_ins[i];
while (opcode_table[i].name)
{
if ((code & WINED3DSI_OPCODE_MASK) == opcode_table[i].opcode
&& shader_version >= opcode_table[i].min_version
&& (!opcode_table[i].max_version || shader_version <= opcode_table[i].max_version))
{
return &opcode_table[i];
}
++i;
}
FIXME("Unsupported opcode %#x(%d) masked %#x, shader version %#x\n",
code, code, code & WINED3DSI_OPCODE_MASK, hex_version);
FIXME("Unsupported opcode %#x(%d) masked %#x, shader version %#x\n",
code, code, code & WINED3DSI_OPCODE_MASK, shader_version);
return NULL;
}
/* Read a parameter opcode from the input stream,
* and possibly a relative addressing token.
* Return the number of tokens read */
int shader_get_param(
IWineD3DBaseShader* iface,
const DWORD* pToken,
DWORD* param,
DWORD* addr_token) {
static int shader_get_param(const DWORD *pToken, DWORD shader_version, DWORD *param, DWORD *addr_token)
{
/* PS >= 3.0 have relative addressing (with token)
* VS >= 2.0 have relative addressing (with token)
* VS >= 1.0 < 2.0 have relative addressing (without token)
* The version check below should work in general */
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
char rel_token = WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 2 &&
char rel_token = WINED3DSHADER_VERSION_MAJOR(shader_version) >= 2 &&
((*pToken & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
*param = *pToken;
@@ -139,11 +136,8 @@ static inline int shader_skip_opcode(
* Note: This function assumes source or destination token format.
* It will not work with specially-formatted tokens like DEF or DCL,
* but hopefully those would be recognized */
int shader_skip_unrecognized(
IWineD3DBaseShader* iface,
const DWORD* pToken) {
static int shader_skip_unrecognized(const DWORD *pToken, DWORD shader_version)
{
int tokens_read = 0;
int i = 0;
@@ -151,12 +145,12 @@ int shader_skip_unrecognized(
while (*pToken & 0x80000000) {
DWORD param, addr_token;
tokens_read += shader_get_param(iface, pToken, &param, &addr_token);
tokens_read += shader_get_param(pToken, shader_version, &param, &addr_token);
pToken += tokens_read;
FIXME("Unrecognized opcode param: token=0x%08x "
"addr_token=0x%08x name=", param, addr_token);
shader_dump_param(iface, param, addr_token, i);
shader_dump_param(param, addr_token, i, shader_version);
FIXME("\n");
++i;
}
@@ -165,9 +159,8 @@ int shader_skip_unrecognized(
/* Convert floating point offset relative
* to a register file to an absolute offset for float constants */
unsigned int shader_get_float_offset(const DWORD reg) {
static unsigned int shader_get_float_offset(const DWORD reg)
{
unsigned int regnum = reg & WINED3DSP_REGNUM_MASK;
int regtype = shader_get_regtype(reg);
@@ -208,6 +201,8 @@ HRESULT shader_get_registers_used(
IWineD3DStateBlockImpl *stateBlock) {
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
const SHADER_OPCODE *shader_ins = This->baseShader.shader_ins;
DWORD shader_version = This->baseShader.hex_version;
unsigned int cur_loop_depth = 0, max_loop_depth = 0;
/* There are some minor differences between pixel and vertex shaders */
@@ -245,7 +240,7 @@ HRESULT shader_get_registers_used(
/* Fetch opcode */
opcode_token = *pToken++;
curOpcode = shader_get_opcode(iface, opcode_token);
curOpcode = shader_get_opcode(shader_ins, shader_version, opcode_token);
/* Unhandled opcode, and its parameters */
if (NULL == curOpcode) {
@@ -425,7 +420,7 @@ HRESULT shader_get_registers_used(
for (i = 0; i < limit; ++i) {
DWORD param, addr_token, reg, regtype;
pToken += shader_get_param(iface, pToken, &param, &addr_token);
pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
regtype = shader_get_regtype(param);
reg = param & WINED3DSP_REGNUM_MASK;
@@ -495,11 +490,8 @@ HRESULT shader_get_registers_used(
return WINED3D_OK;
}
static void shader_dump_decl_usage(
IWineD3DBaseShaderImpl* This,
DWORD decl,
DWORD param) {
static void shader_dump_decl_usage(DWORD decl, DWORD param, DWORD shader_version)
{
DWORD regtype = shader_get_regtype(param);
TRACE("dcl");
@@ -520,8 +512,7 @@ static void shader_dump_decl_usage(
DWORD idx = (decl & WINED3DSP_DCL_USAGEINDEX_MASK) >> WINED3DSP_DCL_USAGEINDEX_SHIFT;
/* Pixel shaders 3.0 don't have usage semantics */
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
if (pshader && This->baseShader.hex_version < WINED3DPS_VERSION(3,0))
if (shader_is_pshader_version(shader_version) && shader_version < WINED3DPS_VERSION(3,0))
return;
else
TRACE("_");
@@ -579,20 +570,16 @@ static void shader_dump_decl_usage(
}
}
static void shader_dump_arr_entry(
IWineD3DBaseShader *iface,
const DWORD param,
const DWORD addr_token,
unsigned int reg,
int input) {
static void shader_dump_arr_entry(const DWORD param, const DWORD addr_token,
unsigned int reg, int input, DWORD shader_version)
{
char relative =
((param & WINED3DSHADER_ADDRESSMODE_MASK) == WINED3DSHADER_ADDRMODE_RELATIVE);
if (relative) {
TRACE("[");
if (addr_token)
shader_dump_param(iface, addr_token, 0, input);
shader_dump_param(addr_token, 0, input, shader_version);
else
TRACE("a0.x");
TRACE(" + ");
@@ -602,13 +589,8 @@ static void shader_dump_arr_entry(
TRACE("]");
}
void shader_dump_param(
IWineD3DBaseShader *iface,
const DWORD param,
const DWORD addr_token,
int input) {
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
static void shader_dump_param(const DWORD param, const DWORD addr_token, int input, DWORD shader_version)
{
static const char * const rastout_reg_names[] = { "oPos", "oFog", "oPts" };
static const char * const misctype_reg_names[] = { "vPos", "vFace"};
char swizzle_reg_chars[4];
@@ -618,7 +600,7 @@ void shader_dump_param(
DWORD modifier = param & WINED3DSP_SRCMOD_MASK;
/* There are some minor differences between pixel and vertex shaders */
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
char pshader = shader_is_pshader_version(shader_version);
/* For one, we'd prefer color components to be shown for pshaders.
* FIXME: use the swizzle function for this */
@@ -650,14 +632,14 @@ void shader_dump_param(
break;
case WINED3DSPR_INPUT:
TRACE("v");
shader_dump_arr_entry(iface, param, addr_token, reg, input);
shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
break;
case WINED3DSPR_CONST:
case WINED3DSPR_CONST2:
case WINED3DSPR_CONST3:
case WINED3DSPR_CONST4:
TRACE("c");
shader_dump_arr_entry(iface, param, addr_token, shader_get_float_offset(param), input);
shader_dump_arr_entry(param, addr_token, shader_get_float_offset(param), input, shader_version);
break;
case WINED3DSPR_TEXTURE: /* vs: case D3DSPR_ADDR */
TRACE("%c%u", (pshader? 't':'a'), reg);
@@ -679,20 +661,20 @@ void shader_dump_param(
/* Vertex shaders >= 3.0 use general purpose output registers
* (WINED3DSPR_OUTPUT), which can include an address token */
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) >= 3) {
if (WINED3DSHADER_VERSION_MAJOR(shader_version) >= 3) {
TRACE("o");
shader_dump_arr_entry(iface, param, addr_token, reg, input);
shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
}
else
TRACE("oT%u", reg);
break;
case WINED3DSPR_CONSTINT:
TRACE("i");
shader_dump_arr_entry(iface, param, addr_token, reg, input);
shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
break;
case WINED3DSPR_CONSTBOOL:
TRACE("b");
shader_dump_arr_entry(iface, param, addr_token, reg, input);
shader_dump_arr_entry(param, addr_token, reg, input, shader_version);
break;
case WINED3DSPR_LABEL:
TRACE("l%u", reg);
@@ -778,19 +760,79 @@ void shader_dump_param(
}
}
static void shader_color_correction(IWineD3DBaseShaderImpl *shader,
IWineD3DDeviceImpl *device, const struct SHADER_OPCODE_ARG *arg)
{
DWORD hex_version = shader->baseShader.hex_version;
IWineD3DBaseTextureImpl *texture;
struct color_fixup_desc fixup;
BOOL recorded = FALSE;
DWORD sampler_idx;
UINT i;
switch(arg->opcode->opcode)
{
case WINED3DSIO_TEX:
if (hex_version < WINED3DPS_VERSION(2,0)) sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
else sampler_idx = arg->src[1] & WINED3DSP_REGNUM_MASK;
break;
case WINED3DSIO_TEXLDL:
FIXME("Add color fixup for vertex texture WINED3DSIO_TEXLDL\n");
return;
case WINED3DSIO_TEXDP3TEX:
case WINED3DSIO_TEXM3x3TEX:
case WINED3DSIO_TEXM3x3SPEC:
case WINED3DSIO_TEXM3x3VSPEC:
case WINED3DSIO_TEXBEM:
case WINED3DSIO_TEXREG2AR:
case WINED3DSIO_TEXREG2GB:
case WINED3DSIO_TEXREG2RGB:
sampler_idx = arg->dst & WINED3DSP_REGNUM_MASK;
break;
default:
/* Not a texture sampling instruction, nothing to do */
return;
};
texture = (IWineD3DBaseTextureImpl *)device->stateBlock->textures[sampler_idx];
if (texture) fixup = texture->baseTexture.shader_color_fixup;
else fixup = COLOR_FIXUP_IDENTITY;
/* before doing anything, record the sampler with the format in the format conversion list,
* but check if it's not there already */
for (i = 0; i < shader->baseShader.num_sampled_samplers; ++i)
{
if (shader->baseShader.sampled_samplers[i] == sampler_idx)
{
recorded = TRUE;
break;
}
}
if (!recorded)
{
shader->baseShader.sampled_samplers[shader->baseShader.num_sampled_samplers] = sampler_idx;
++shader->baseShader.num_sampled_samplers;
}
device->shader_backend->shader_color_correction(arg, fixup);
}
/** Shared code in order to generate the bulk of the shader string.
Use the shader_header_fct & shader_footer_fct to add strings
that are specific to pixel or vertex functions
NOTE: A description of how to parse tokens can be found on msdn */
void shader_generate_main(
IWineD3DBaseShader *iface,
SHADER_BUFFER* buffer,
shader_reg_maps* reg_maps,
CONST DWORD* pFunction) {
void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer,
const shader_reg_maps* reg_maps, CONST DWORD* pFunction)
{
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) This->baseShader.device; /* To access shader backend callbacks */
const SHADER_OPCODE *opcode_table = This->baseShader.shader_ins;
const SHADER_HANDLER *handler_table = device->shader_backend->shader_instruction_handler_table;
DWORD shader_version = This->baseShader.hex_version;
const DWORD *pToken = pFunction;
const SHADER_OPCODE *curOpcode = NULL;
SHADER_HANDLER hw_fct = NULL;
@@ -824,7 +866,7 @@ void shader_generate_main(
/* Read opcode */
hw_arg.opcode_token = *pToken++;
curOpcode = shader_get_opcode(iface, hw_arg.opcode_token);
curOpcode = shader_get_opcode(opcode_table, shader_version, hw_arg.opcode_token);
/* Select handler */
if (curOpcode == NULL)
@@ -835,7 +877,7 @@ void shader_generate_main(
/* Unknown opcode and its parameters */
if (NULL == curOpcode) {
FIXME("Unrecognized opcode: token=0x%08x\n", hw_arg.opcode_token);
pToken += shader_skip_unrecognized(iface, pToken);
pToken += shader_skip_unrecognized(pToken, shader_version);
/* Nothing to do */
} else if (WINED3DSIO_DCL == curOpcode->opcode ||
@@ -857,7 +899,7 @@ void shader_generate_main(
if (curOpcode->dst_token) {
DWORD param, addr_token = 0;
pToken += shader_get_param(iface, pToken, &param, &addr_token);
pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
hw_arg.dst = param;
hw_arg.dst_addr = addr_token;
}
@@ -870,7 +912,7 @@ void shader_generate_main(
for (i = 0; i < (curOpcode->num_params - curOpcode->dst_token); i++) {
DWORD param, addr_token = 0;
pToken += shader_get_param(iface, pToken, &param, &addr_token);
pToken += shader_get_param(pToken, shader_version, &param, &addr_token);
hw_arg.src[i] = param;
hw_arg.src_addr[i] = addr_token;
}
@@ -879,7 +921,7 @@ void shader_generate_main(
hw_fct(&hw_arg);
/* Add color correction if needed */
device->shader_backend->shader_color_correction(&hw_arg);
shader_color_correction(This, device, &hw_arg);
/* Process instruction modifiers for GLSL apps ( _sat, etc. ) */
/* FIXME: This should be internal to the shader backend.
@@ -899,8 +941,8 @@ void shader_generate_main(
}
}
void shader_dump_ins_modifiers(const DWORD output) {
static void shader_dump_ins_modifiers(const DWORD output)
{
DWORD shift = (output & WINED3DSP_DSTSHIFT_MASK) >> WINED3DSP_DSTSHIFT_SHIFT;
DWORD mmask = output & WINED3DSP_DSTMOD_MASK;
@@ -939,155 +981,167 @@ void shader_trace_init(
TRACE("(%p) : Parsing program\n", This);
if (NULL != pToken) {
while (WINED3DVS_END() != *pToken) {
if (shader_is_version_token(*pToken)) { /** version */
This->baseShader.hex_version = *pToken;
TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
WINED3DSHADER_VERSION_MINOR(This->baseShader.hex_version));
++pToken;
++len;
continue;
}
if (shader_is_comment(*pToken)) { /** comment */
DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
++pToken;
TRACE("//%s\n", (const char*)pToken);
pToken += comment_len;
len += comment_len + 1;
continue;
}
opcode_token = *pToken++;
curOpcode = shader_get_opcode(iface, opcode_token);
len++;
if (!pFunction)
{
WARN("Got a NULL pFunction, returning.\n");
This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
return;
}
if (NULL == curOpcode) {
while (WINED3DVS_END() != *pToken)
{
if (shader_is_version_token(*pToken)) /* version */
{
This->baseShader.hex_version = *pToken;
TRACE("%s_%u_%u\n", shader_is_pshader_version(This->baseShader.hex_version)? "ps": "vs",
WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version),
WINED3DSHADER_VERSION_MINOR(This->baseShader.hex_version));
++pToken;
++len;
continue;
}
if (shader_is_comment(*pToken)) /* comment */
{
DWORD comment_len = (*pToken & WINED3DSI_COMMENTSIZE_MASK) >> WINED3DSI_COMMENTSIZE_SHIFT;
++pToken;
TRACE("//%s\n", (const char*)pToken);
pToken += comment_len;
len += comment_len + 1;
continue;
}
opcode_token = *pToken++;
curOpcode = shader_get_opcode(This->baseShader.shader_ins, This->baseShader.hex_version, opcode_token);
len++;
if (!curOpcode)
{
int tokens_read;
FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
tokens_read = shader_skip_unrecognized(pToken, This->baseShader.hex_version);
pToken += tokens_read;
len += tokens_read;
}
else
{
if (curOpcode->opcode == WINED3DSIO_DCL)
{
DWORD usage = *pToken;
DWORD param = *(pToken + 1);
shader_dump_decl_usage(usage, param, This->baseShader.hex_version);
shader_dump_ins_modifiers(param);
TRACE(" ");
shader_dump_param(param, 0, 0, This->baseShader.hex_version);
pToken += 2;
len += 2;
}
else if (curOpcode->opcode == WINED3DSIO_DEF)
{
unsigned int offset = shader_get_float_offset(*pToken);
TRACE("def c%u = %f, %f, %f, %f", offset,
*(const float *)(pToken + 1),
*(const float *)(pToken + 2),
*(const float *)(pToken + 3),
*(const float *)(pToken + 4));
pToken += 5;
len += 5;
}
else if (curOpcode->opcode == WINED3DSIO_DEFI)
{
TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1),
*(pToken + 2),
*(pToken + 3),
*(pToken + 4));
pToken += 5;
len += 5;
}
else if (curOpcode->opcode == WINED3DSIO_DEFB)
{
TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1)? "true": "false");
pToken += 2;
len += 2;
}
else
{
DWORD param, addr_token;
int tokens_read;
FIXME("Unrecognized opcode: token=0x%08x\n", opcode_token);
tokens_read = shader_skip_unrecognized(iface, pToken);
pToken += tokens_read;
len += tokens_read;
} else {
if (curOpcode->opcode == WINED3DSIO_DCL) {
/* Print out predication source token first - it follows
* the destination token. */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
{
TRACE("(");
shader_dump_param(*(pToken + 2), 0, 1, This->baseShader.hex_version);
TRACE(") ");
}
if (opcode_token & WINED3DSI_COISSUE)
{
/* PixWin marks instructions with the coissue flag with a '+' */
TRACE("+");
}
DWORD usage = *pToken;
DWORD param = *(pToken + 1);
TRACE("%s", curOpcode->name);
shader_dump_decl_usage(This, usage, param);
shader_dump_ins_modifiers(param);
TRACE(" ");
shader_dump_param(iface, param, 0, 0);
pToken += 2;
len += 2;
if (curOpcode->opcode == WINED3DSIO_IFC
|| curOpcode->opcode == WINED3DSIO_BREAKC)
{
DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
} else if (curOpcode->opcode == WINED3DSIO_DEF) {
unsigned int offset = shader_get_float_offset(*pToken);
TRACE("def c%u = %f, %f, %f, %f", offset,
*(const float *)(pToken + 1),
*(const float *)(pToken + 2),
*(const float *)(pToken + 3),
*(const float *)(pToken + 4));
pToken += 5;
len += 5;
} else if (curOpcode->opcode == WINED3DSIO_DEFI) {
TRACE("defi i%u = %d, %d, %d, %d", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1),
*(pToken + 2),
*(pToken + 3),
*(pToken + 4));
pToken += 5;
len += 5;
} else if (curOpcode->opcode == WINED3DSIO_DEFB) {
TRACE("defb b%u = %s", *pToken & WINED3DSP_REGNUM_MASK,
*(pToken + 1)? "true": "false");
pToken += 2;
len += 2;
} else {
DWORD param, addr_token;
int tokens_read;
/* Print out predication source token first - it follows
* the destination token. */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
TRACE("(");
shader_dump_param(iface, *(pToken + 2), 0, 1);
TRACE(") ");
}
if (opcode_token & WINED3DSI_COISSUE) {
/* PixWin marks instructions with the coissue flag with a '+' */
TRACE("+");
}
TRACE("%s", curOpcode->name);
if (curOpcode->opcode == WINED3DSIO_IFC ||
curOpcode->opcode == WINED3DSIO_BREAKC) {
DWORD op = (opcode_token & INST_CONTROLS_MASK) >> INST_CONTROLS_SHIFT;
switch (op) {
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)", op);
}
} else if (curOpcode->opcode == WINED3DSIO_TEX &&
This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)) {
if(opcode_token & WINED3DSI_TEXLD_PROJECT) TRACE("p");
}
/* Destination token */
if (curOpcode->dst_token) {
/* Destination token */
tokens_read = shader_get_param(iface, pToken, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
shader_dump_ins_modifiers(param);
TRACE(" ");
shader_dump_param(iface, param, addr_token, 0);
}
/* Predication token - already printed out, just skip it */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED) {
pToken++;
len++;
}
/* Other source tokens */
for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i) {
tokens_read = shader_get_param(iface, pToken, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
TRACE((i == 0)? " " : ", ");
shader_dump_param(iface, param, addr_token, 1);
switch (op)
{
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)", op);
}
}
TRACE("\n");
else if (curOpcode->opcode == WINED3DSIO_TEX
&& This->baseShader.hex_version >= WINED3DPS_VERSION(2,0)
&& (opcode_token & WINED3DSI_TEXLD_PROJECT))
{
TRACE("p");
}
/* Destination token */
if (curOpcode->dst_token)
{
tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
shader_dump_ins_modifiers(param);
TRACE(" ");
shader_dump_param(param, addr_token, 0, This->baseShader.hex_version);
}
/* Predication token - already printed out, just skip it */
if (opcode_token & WINED3DSHADER_INSTRUCTION_PREDICATED)
{
pToken++;
len++;
}
/* Other source tokens */
for (i = curOpcode->dst_token; i < curOpcode->num_params; ++i)
{
tokens_read = shader_get_param(pToken, This->baseShader.hex_version, &param, &addr_token);
pToken += tokens_read;
len += tokens_read;
TRACE((i == 0)? " " : ", ");
shader_dump_param(param, addr_token, 1, This->baseShader.hex_version);
}
}
TRACE("\n");
}
This->baseShader.functionLength = (len + 1) * sizeof(DWORD);
} else {
This->baseShader.functionLength = 1; /* no Function defined use fixed function vertex processing */
}
This->baseShader.functionLength = (len + 1) * sizeof(DWORD);
}
static const SHADER_HANDLER shader_none_instruction_handler_table[WINED3DSIH_TABLE_SIZE] = {0};
@@ -1096,41 +1150,45 @@ static void shader_none_select_depth_blt(IWineD3DDevice *iface, enum tex_types t
static void shader_none_deselect_depth_blt(IWineD3DDevice *iface) {}
static void shader_none_load_constants(IWineD3DDevice *iface, char usePS, char useVS) {}
static void shader_none_cleanup(IWineD3DDevice *iface) {}
static void shader_none_color_correction(SHADER_OPCODE_ARG* arg) {}
static void shader_none_color_correction(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup) {}
static void shader_none_destroy(IWineD3DBaseShader *iface) {}
static HRESULT shader_none_alloc(IWineD3DDevice *iface) {return WINED3D_OK;}
static void shader_none_free(IWineD3DDevice *iface) {}
static BOOL shader_none_dirty_const(IWineD3DDevice *iface) {return FALSE;}
static void shader_none_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
static GLuint shader_none_generate_pshader(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer) {
FIXME("NONE shader backend asked to generate a pixel shader\n");
return 0;
}
static void shader_none_generate_vshader(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer) {
FIXME("NONE shader backend asked to generate a vertex shader\n");
}
#define GLINFO_LOCATION (*gl_info)
static void shader_none_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *pCaps) {
static void shader_none_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *pCaps)
{
/* Set the shader caps to 0 for the none shader backend */
pCaps->VertexShaderVersion = 0;
pCaps->PixelShaderVersion = 0;
pCaps->PixelShader1xMaxValue = 0.0;
}
#undef GLINFO_LOCATION
static BOOL shader_none_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s", debug_d3dformat(fmt));
switch(fmt) {
/* Faked to make some apps happy. */
case WINED3DFMT_V8U8:
case WINED3DFMT_V16U16:
case WINED3DFMT_L6V5U5:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_Q8W8V8U8:
TRACE("[OK]\n");
return TRUE;
default:
TRACE("[FAILED]\n");
return FALSE;
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);
}
/* Faked to make some apps happy. */
if (!is_yuv_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
}
const shader_backend_t none_shader_backend = {
@@ -1148,7 +1206,7 @@ const shader_backend_t none_shader_backend = {
shader_none_generate_pshader,
shader_none_generate_vshader,
shader_none_get_caps,
shader_none_conv_supported
shader_none_color_fixup_supported,
};
/* *******************************************
+30 -161
View File
@@ -27,46 +27,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DBaseTexture IUnknown parts follow
******************************************* */
HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, LPVOID *ppobj)
void basetexture_cleanup(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DResource)
|| IsEqualGUID(riid, &IID_IWineD3DBaseTexture)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %d\n", This,ref - 1);
return ref;
}
ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (ref == 0) {
IWineD3DBaseTextureImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* class static */
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
@@ -78,41 +40,12 @@ void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
}
/* ****************************************************
IWineD3DBaseTexture IWineD3DResource parts follow
**************************************************** */
HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
}
void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
}
void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface) {
void basetexture_unload(IWineD3DBaseTexture *iface)
{
IWineD3DTextureImpl *This = (IWineD3DTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
@@ -126,21 +59,10 @@ void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface
This->baseTexture.dirty = TRUE;
}
WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
}
HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DBaseTexture IWineD3DBaseTexture parts follow
****************************************************** */
/* There is no OpenGL equivalent of setLOD, getLOD. All they do anyway is prioritize texture loading
* so just pretend that they work unless something really needs a failure. */
DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew) {
DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD LODNew)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -156,7 +78,8 @@ DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LO
return This->baseTexture.LOD;
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
if (This->resource.pool != WINED3DPOOL_MANAGED) {
@@ -168,13 +91,15 @@ DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface) {
return This->baseTexture.LOD;
}
DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface) {
DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->baseTexture.levels);
return This->baseTexture.levels;
}
HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
UINT textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -216,7 +141,8 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture
return WINED3D_OK;
}
WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface) {
WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : stub\n", This);
if (!(This->resource.usage & WINED3DUSAGE_AUTOGENMIPMAP)) {
@@ -225,15 +151,16 @@ WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWi
return This->baseTexture.filterType;
}
void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface) {
void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
/* TODO: implement filters using GL_SGI_generate_mipmaps http://oss.sgi.com/projects/ogl-sample/registry/SGIS/generate_mipmap.txt */
FIXME("(%p) : stub\n", This);
return ;
}
/* Internal function, No d3d mapping */
BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL dirty) {
BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty)
{
BOOL old;
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
old = This->baseTexture.dirty;
@@ -241,12 +168,14 @@ BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL di
return old;
}
BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface) {
BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
return This->baseTexture.dirty;
}
HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
HRESULT basetexture_bind(IWineD3DBaseTexture *iface)
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
HRESULT hr = WINED3D_OK;
UINT textureDimensions;
@@ -330,32 +259,6 @@ HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface) {
return hr;
}
UINT WINAPI IWineD3DBaseTextureImpl_GetTextureDimensions(IWineD3DBaseTexture *iface){
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
return WINED3D_OK;
}
BOOL WINAPI IWineD3DBaseTextureImpl_IsCondNP2(IWineD3DBaseTexture *iface){
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
FIXME("(%p) : This shouldn't be called\n", This);
return FALSE;
}
static inline GLenum warpLookupType(WINED3DSAMPLERSTATETYPE Type) {
switch(Type) {
case WINED3DSAMP_ADDRESSU:
return GL_TEXTURE_WRAP_S;
case WINED3DSAMP_ADDRESSV:
return GL_TEXTURE_WRAP_T;
case WINED3DSAMP_ADDRESSW:
return GL_TEXTURE_WRAP_R;
default:
FIXME("Unexpected warp type %d\n", Type);
return 0;
}
}
static inline void apply_wrap(const GLint textureDimensions, const DWORD state, const GLint type,
BOOL cond_np2) {
GLint wrapParm;
@@ -381,9 +284,10 @@ static inline void apply_wrap(const GLint textureDimensions, const DWORD state,
}
}
void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1])
{
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
DWORD state;
GLint textureDimensions = IWineD3DBaseTexture_GetTextureDimensions(iface);
@@ -426,7 +330,7 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
if (state > WINED3DTEXF_ANISOTROPIC) {
FIXME("Unrecognized or unsupported MAGFILTER* value %d\n", state);
} else {
glValue = (*This->baseTexture.magLookup)[state - WINED3DTEXF_NONE];
glValue = This->baseTexture.magLookup[state - WINED3DTEXF_NONE];
TRACE("ValueMAG=%d setting MAGFILTER to %x\n", state, glValue);
glTexParameteri(textureDimensions, GL_TEXTURE_MAG_FILTER, glValue);
/* We need to reset the Anisotropic filtering state when we change the mag filter to WINED3DTEXF_ANISOTROPIC (this seems a bit weird, check the documentation to see how it should be switched off. */
@@ -455,9 +359,9 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
This->baseTexture.states[WINED3DTEXSTA_MINFILTER],
This->baseTexture.states[WINED3DTEXSTA_MIPFILTER]);
}
glValue = (*This->baseTexture.minMipLookup)
glValue = This->baseTexture.minMipLookup
[min(max(samplerStates[WINED3DSAMP_MINFILTER],WINED3DTEXF_NONE), WINED3DTEXF_ANISOTROPIC)]
[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
.mip[min(max(samplerStates[WINED3DSAMP_MIPFILTER],WINED3DTEXF_NONE), WINED3DTEXF_LINEAR)];
TRACE("ValueMIN=%d, ValueMIP=%d, setting MINFILTER to %x\n",
samplerStates[WINED3DSAMP_MINFILTER],
@@ -487,38 +391,3 @@ void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface
This->baseTexture.states[WINED3DTEXSTA_MAXANISOTROPY] = samplerStates[WINED3DSAMP_MAXANISOTROPY];
}
}
static const IWineD3DBaseTextureVtbl IWineD3DBaseTexture_Vtbl =
{
/* IUnknown */
IWineD3DBaseTextureImpl_QueryInterface,
IWineD3DBaseTextureImpl_AddRef,
IWineD3DBaseTextureImpl_Release,
/* IWineD3DResource */
IWineD3DBaseTextureImpl_GetParent,
IWineD3DBaseTextureImpl_GetDevice,
IWineD3DBaseTextureImpl_SetPrivateData,
IWineD3DBaseTextureImpl_GetPrivateData,
IWineD3DBaseTextureImpl_FreePrivateData,
IWineD3DBaseTextureImpl_SetPriority,
IWineD3DBaseTextureImpl_GetPriority,
IWineD3DBaseTextureImpl_PreLoad,
IWineD3DBaseTextureImpl_UnLoad,
IWineD3DBaseTextureImpl_GetType,
/*IWineD3DBaseTexture*/
IWineD3DBaseTextureImpl_SetLOD,
IWineD3DBaseTextureImpl_GetLOD,
IWineD3DBaseTextureImpl_GetLevelCount,
IWineD3DBaseTextureImpl_SetAutoGenFilterType,
IWineD3DBaseTextureImpl_GetAutoGenFilterType,
IWineD3DBaseTextureImpl_GenerateMipSubLevels,
IWineD3DBaseTextureImpl_SetDirty,
IWineD3DBaseTextureImpl_GetDirty,
/* internal */
IWineD3DBaseTextureImpl_BindTexture,
IWineD3DBaseTextureImpl_GetTextureDimensions,
IWineD3DBaseTextureImpl_IsCondNP2,
IWineD3DBaseTextureImpl_ApplyStateChanges
};
+3 -2
View File
@@ -96,7 +96,8 @@ static HRESULT WINAPI IWineD3DClipperImpl_SetHwnd(IWineD3DClipper *iface, DWORD
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RECT *Rect, RGNDATA *ClipList, DWORD *Size)
static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, const RECT *Rect,
RGNDATA *ClipList, DWORD *Size)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
TRACE("(%p,%p,%p,%p)\n", This, Rect, ClipList, Size);
@@ -140,7 +141,7 @@ static HRESULT WINAPI IWineD3DClipperImpl_GetClipList(IWineD3DClipper *iface, RE
}
}
static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, RGNDATA *rgn, DWORD Flags)
static HRESULT WINAPI IWineD3DClipperImpl_SetClipList(IWineD3DClipper *iface, const RGNDATA *rgn, DWORD Flags)
{
IWineD3DClipperImpl *This = (IWineD3DClipperImpl *)iface;
static int warned = 0;
+1 -1
View File
@@ -1253,7 +1253,7 @@ static inline WineD3DContext *FindContext(IWineD3DDeviceImpl *This, IWineD3DSurf
* the alpha blend state changes with different render target formats
*/
if(oldFmt != newFmt) {
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *old = getFormatDescEntry(oldFmt, NULL, NULL);
const StaticPixelFormatDesc *new = getFormatDescEntry(newFmt, &GLINFO_LOCATION, &glDesc);
+20 -20
View File
@@ -68,27 +68,27 @@ static ULONG WINAPI IWineD3DCubeTextureImpl_Release(IWineD3DCubeTexture *iface)
IWineD3DCubeTexture IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetDevice(IWineD3DCubeTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetPrivateData(IWineD3DCubeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_FreePrivateData(IWineD3DCubeTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_SetPriority(IWineD3DCubeTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetPriority(IWineD3DCubeTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DCubeTextureImpl_PreLoad(IWineD3DCubeTexture *iface) {
@@ -176,52 +176,52 @@ static void WINAPI IWineD3DCubeTextureImpl_UnLoad(IWineD3DCubeTexture *iface) {
}
}
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
basetexture_unload((IWineD3DBaseTexture *)iface);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DCubeTextureImpl_GetType(IWineD3DCubeTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_GetParent(IWineD3DCubeTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DCubeTexture IWineD3DBaseTexture parts follow
****************************************************** */
static DWORD WINAPI IWineD3DCubeTextureImpl_SetLOD(IWineD3DCubeTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLOD(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
return basetexture_get_lod((IWineD3DBaseTexture *)iface);
}
static DWORD WINAPI IWineD3DCubeTextureImpl_GetLevelCount(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_SetAutoGenFilterType(IWineD3DCubeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
}
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DCubeTextureImpl_GetAutoGenFilterType(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
}
static void WINAPI IWineD3DCubeTextureImpl_GenerateMipSubLevels(IWineD3DCubeTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_SetDirty(IWineD3DCubeTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DCubeTextureImpl_GetDirty(IWineD3DCubeTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *iface) {
@@ -231,7 +231,7 @@ static HRESULT WINAPI IWineD3DCubeTextureImpl_BindTexture(IWineD3DCubeTexture *i
TRACE("(%p) : relay to BaseTexture\n", This);
hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
hr = basetexture_bind((IWineD3DBaseTexture *)iface);
if (set_gl_texture_desc && SUCCEEDED(hr)) {
UINT i, j;
for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -262,7 +262,7 @@ static void WINAPI IWineD3DCubeTextureImpl_ApplyStateChanges(IWineD3DCubeTexture
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
@@ -286,7 +286,7 @@ static void WINAPI IWineD3DCubeTextureImpl_Destroy(IWineD3DCubeTexture *iface, D
}
}
}
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
basetexture_cleanup((IWineD3DBaseTexture *)iface);
/* finally delete the object */
HeapFree(GetProcessHeap(), 0, This);
}
+117 -89
View File
@@ -52,7 +52,7 @@ const WINED3DLIGHT WINED3D_default_light = {
};
/* static function declarations */
static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource);
static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource);
/* helper macros */
#define D3DMEMCHECK(object, ppResult) if(NULL == object) { *ppResult = NULL; WARN("Out of memory\n"); return WINED3DERR_OUTOFVIDEOMEMORY;}
@@ -457,12 +457,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
object->num_contained_ps_consts_f = GL_LIMITS(pshader_constantsF);
for (i = 0; i < MAX_CONST_B; ++i) {
object->contained_ps_consts_b[i] = i;
object->changed.pixelShaderConstantsB[i] = TRUE;
object->changed.pixelShaderConstantsB |= (1 << i);
}
object->num_contained_ps_consts_b = MAX_CONST_B;
for (i = 0; i < MAX_CONST_I; ++i) {
object->contained_ps_consts_i[i] = i;
object->changed.pixelShaderConstantsI[i] = TRUE;
object->changed.pixelShaderConstantsI |= (1 << i);
}
object->num_contained_ps_consts_i = MAX_CONST_I;
@@ -514,13 +514,13 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateStateBlock(IWineD3DDevice* iface,
}
object->num_contained_vs_consts_f = GL_LIMITS(vshader_constantsF);
for (i = 0; i < MAX_CONST_B; ++i) {
object->changed.vertexShaderConstantsB[i] = TRUE;
object->contained_vs_consts_b[i] = i;
object->changed.vertexShaderConstantsB |= (1 << i);
}
object->num_contained_vs_consts_b = MAX_CONST_B;
for (i = 0; i < MAX_CONST_I; ++i) {
object->changed.vertexShaderConstantsI[i] = TRUE;
object->contained_vs_consts_i[i] = i;
object->changed.vertexShaderConstantsI |= (1 << i);
}
object->num_contained_vs_consts_i = MAX_CONST_I;
for (i = 0; i < NUM_SAVEDVERTEXSTATES_R; i++) {
@@ -587,7 +587,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateSurface(IWineD3DDevice *iface, U
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *object; /*NOTE: impl ref allowed since this is a create function */
unsigned int Size = 1;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
UINT mul_4w, mul_4h;
TRACE("(%p) Create surface\n",This);
@@ -759,7 +759,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
HRESULT hr;
unsigned int pow2Width;
unsigned int pow2Height;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : Width %d, Height %d, Levels %d, Usage %#x\n", This, Width, Height, Levels, Usage);
@@ -779,11 +779,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->height = Height;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/** Non-power2 support **/
@@ -821,7 +821,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->baseTexture.pow2Matrix[15] = 1.0;
object->target = GL_TEXTURE_2D;
object->cond_np2 = TRUE;
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
} else if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE) &&
(Width != pow2Width || Height != pow2Height) &&
!((Format == WINED3DFMT_P8) && GL_SUPPORT(EXT_PALETTED_TEXTURE) && (wined3d_settings.rendertargetlock_mode == RTL_READTEX || wined3d_settings.rendertargetlock_mode == RTL_TEXTEX)))
@@ -832,7 +832,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
object->baseTexture.pow2Matrix[15] = 1.0;
object->target = GL_TEXTURE_RECTANGLE_ARB;
object->cond_np2 = TRUE;
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
} else {
object->baseTexture.pow2Matrix[0] = (((float)Width) / ((float)pow2Width));
object->baseTexture.pow2Matrix[5] = (((float)Height) / ((float)pow2Height));
@@ -891,7 +891,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateTexture(IWineD3DDevice *iface, U
tmpW = max(1, tmpW >> 1);
tmpH = max(1, tmpH >> 1);
}
object->baseTexture.shader_conversion_group = glDesc->conversion_group;
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
TRACE("(%p) : Created texture %p\n", This, object);
return WINED3D_OK;
@@ -911,7 +911,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
UINT tmpW;
UINT tmpH;
UINT tmpD;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
@@ -932,10 +932,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
TRACE("(%p) : W(%d) H(%d) D(%d), Lvl(%d) Usage(%d), Fmt(%u,%s), Pool(%s)\n", This, Width, Height,
Depth, Levels, Usage, Format, debug_d3dformat(Format), debug_d3dpool(Pool));
object->width = Width;
object->height = Height;
object->depth = Depth;
/* Is NP2 support for volumes needed? */
object->baseTexture.pow2Matrix[ 0] = 1.0;
object->baseTexture.pow2Matrix[ 5] = 1.0;
@@ -943,11 +939,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
object->baseTexture.pow2Matrix[15] = 1.0;
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/* Calculate levels for mip mapping */
@@ -1002,7 +998,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVolumeTexture(IWineD3DDevice *ifa
tmpH = max(1, tmpH >> 1);
tmpD = max(1, tmpD >> 1);
}
object->baseTexture.shader_conversion_group = glDesc->conversion_group;
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
*ppVolumeTexture = (IWineD3DVolumeTexture *) object;
TRACE("(%p) : Created volume texture %p\n", This, object);
@@ -1057,7 +1053,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
UINT tmpW;
HRESULT hr;
unsigned int pow2EdgeLength;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(Format, &GLINFO_LOCATION, &glDesc);
/* TODO: It should only be possible to create textures for formats
@@ -1081,8 +1077,6 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
pow2EdgeLength = 1;
while (pow2EdgeLength < EdgeLength) pow2EdgeLength <<= 1;
object->edgeLength = EdgeLength;
if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) {
/* Precalculated scaling for 'faked' non power of two texture coords */
object->baseTexture.pow2Matrix[ 0] = 1.0;
@@ -1098,11 +1092,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
}
if(glDesc->Flags & WINED3DFMT_FLAG_FILTERING) {
object->baseTexture.minMipLookup = &minMipLookup;
object->baseTexture.magLookup = &magLookup;
object->baseTexture.minMipLookup = minMipLookup;
object->baseTexture.magLookup = magLookup;
} else {
object->baseTexture.minMipLookup = &minMipLookup_noFilter;
object->baseTexture.magLookup = &magLookup_noFilter;
object->baseTexture.minMipLookup = minMipLookup_noFilter;
object->baseTexture.magLookup = magLookup_noFilter;
}
/* Calculate levels for mip mapping */
@@ -1174,7 +1168,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface
}
tmpW = max(1, tmpW >> 1);
}
object->baseTexture.shader_conversion_group = glDesc->conversion_group;
object->baseTexture.shader_color_fixup = glDesc->color_fixup;
TRACE("(%p) : Created Cube Texture %p\n", This, object);
*ppCubeTexture = (IWineD3DCubeTexture *) object;
@@ -1243,13 +1237,19 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
if(GL_SUPPORT(ARB_OCCLUSION_QUERY)) {
TRACE("(%p) Allocating data for an occlusion query\n", This);
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
GL_EXTCALL(glGenQueriesARB(1, &((WineQueryOcclusionData *)(object->extendedData))->queryId));
LEAVE_GL();
break;
}
case WINED3DQUERYTYPE_EVENT:
object->extendedData = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineQueryEventData));
((WineQueryEventData *)(object->extendedData))->ctx = This->activeContext;
ActivateContext(This, This->lastActiveRenderTarget, CTXUSAGE_RESOURCELOAD);
ENTER_GL();
if(GL_SUPPORT(APPLE_FENCE)) {
GL_EXTCALL(glGenFencesAPPLE(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
checkGLcall("glGenFencesAPPLE");
@@ -1257,6 +1257,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE
GL_EXTCALL(glGenFencesNV(1, &((WineQueryEventData *)(object->extendedData))->fenceId));
checkGLcall("glGenFencesNV");
}
LEAVE_GL();
break;
case WINED3DQUERYTYPE_VCACHE:
@@ -1311,7 +1312,7 @@ static LONG fullscreen_exStyle(LONG orig_exStyle) {
return exStyle;
}
static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) {
static void IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *iface, HWND window, UINT w, UINT h) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
LONG style, exStyle;
@@ -1355,7 +1356,7 @@ static void WINAPI IWineD3DDeviceImpl_SetupFullscreenWindow(IWineD3DDevice *ifac
* window: Window to setup
*
*****************************************************************************/
static void WINAPI IWineD3DDeviceImpl_RestoreWindow(IWineD3DDevice *iface, HWND window) {
static void IWineD3DDeviceImpl_RestoreWindow(IWineD3DDevice *iface, HWND window) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
LONG style, exStyle;
@@ -1934,7 +1935,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreatePixelShader(IWineD3DDevice *iface
return hr;
}
static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags, PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent) {
static HRESULT WINAPI IWineD3DDeviceImpl_CreatePalette(IWineD3DDevice *iface, DWORD Flags,
const PALETTEENTRY *PalEnt, IWineD3DPalette **Palette, IUnknown *Parent)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DPaletteImpl *object;
HRESULT hr;
@@ -2478,7 +2481,8 @@ static void WINAPI IWineD3DDeviceImpl_SetMultithreaded(IWineD3DDevice *iface) {
return;
}
static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain, WINED3DDISPLAYMODE* pMode) {
static HRESULT WINAPI IWineD3DDeviceImpl_SetDisplayMode(IWineD3DDevice *iface, UINT iSwapChain,
const WINED3DDISPLAYMODE* pMode) {
DEVMODEW devmode;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
LONG ret;
@@ -2772,7 +2776,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetTransform(IWineD3DDevice *iface, WIN
}
static HRESULT WINAPI IWineD3DDeviceImpl_MultiplyTransform(IWineD3DDevice *iface, WINED3DTRANSFORMSTATETYPE State, CONST WINED3DMATRIX* pMatrix) {
WINED3DMATRIX *mat = NULL;
const WINED3DMATRIX *mat = NULL;
WINED3DMATRIX temp;
/* Note: Using 'updateStateBlock' rather than 'stateblock' in the code
@@ -3541,7 +3545,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantB(
TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
for (i = start; i < cnt + start; ++i) {
This->updateStateBlock->changed.vertexShaderConstantsB[i] = TRUE;
This->updateStateBlock->changed.vertexShaderConstantsB |= (1 << i);
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
@@ -3589,7 +3593,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetVertexShaderConstantI(
srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
for (i = start; i < cnt + start; ++i) {
This->updateStateBlock->changed.vertexShaderConstantsI[i] = TRUE;
This->updateStateBlock->changed.vertexShaderConstantsI |= (1 << i);
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VERTEXSHADERCONSTANT);
@@ -3806,7 +3810,8 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
}
static void device_map_psamplers(IWineD3DDeviceImpl *This) {
DWORD *sampler_tokens = ((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.samplers;
const DWORD *sampler_tokens =
((IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader)->baseShader.reg_maps.samplers;
int i;
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
@@ -3820,7 +3825,9 @@ static void device_map_psamplers(IWineD3DDeviceImpl *This) {
}
}
static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, DWORD *pshader_sampler_tokens, DWORD *vshader_sampler_tokens, int unit) {
static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, const DWORD *pshader_sampler_tokens,
const DWORD *vshader_sampler_tokens, int unit)
{
int current_mapping = This->rev_tex_unit_map[unit];
if (current_mapping == -1) {
@@ -3845,8 +3852,9 @@ static BOOL device_unit_free_for_vs(IWineD3DDeviceImpl *This, DWORD *pshader_sam
}
static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
DWORD *vshader_sampler_tokens = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.samplers;
DWORD *pshader_sampler_tokens = NULL;
const DWORD *vshader_sampler_tokens =
((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.samplers;
const DWORD *pshader_sampler_tokens = NULL;
int start = GL_LIMITS(combined_samplers) - 1;
int i;
@@ -3854,7 +3862,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) {
IWineD3DPixelShaderImpl *pshader = (IWineD3DPixelShaderImpl *)This->stateBlock->pixelShader;
/* Make sure the shader's reg_maps are up to date. This is only relevant for 1.x pixelshaders. */
IWineD3DPixelShader_CompileShader((IWineD3DPixelShader *)pshader);
IWineD3DPixelShader_UpdateSamplers((IWineD3DPixelShader *)pshader);
pshader_sampler_tokens = pshader->baseShader.reg_maps.samplers;
}
@@ -3970,7 +3978,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantB(
TRACE("Set BOOL constant %u to %s\n", start + i, srcData[i]? "true":"false");
for (i = start; i < cnt + start; ++i) {
This->updateStateBlock->changed.pixelShaderConstantsB[i] = TRUE;
This->updateStateBlock->changed.pixelShaderConstantsB |= (1 << i);
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
@@ -4018,7 +4026,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetPixelShaderConstantI(
srcData[i*4], srcData[i*4+1], srcData[i*4+2], srcData[i*4+3]);
for (i = start; i < cnt + start; ++i) {
This->updateStateBlock->changed.pixelShaderConstantsI[i] = TRUE;
This->updateStateBlock->changed.pixelShaderConstantsI |= (1 << i);
}
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_PIXELSHADERCONSTANT);
@@ -4140,8 +4148,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetPixelShaderConstantF(
}
#define copy_and_next(dest, src, size) memcpy(dest, src, size); dest += (size)
static HRESULT
process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount, WineDirect3DVertexStridedData *lpStrideData, IWineD3DVertexBufferImpl *dest, DWORD dwFlags) {
static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCount,
const WineDirect3DVertexStridedData *lpStrideData, IWineD3DVertexBufferImpl *dest, DWORD dwFlags)
{
char *dest_ptr, *dest_conv = NULL, *dest_conv_addr = NULL;
unsigned int i;
DWORD DestFVF = dest->fvf;
@@ -4173,7 +4182,7 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
return E_OUTOFMEMORY;
}
if(dest->vbo) {
void *src;
const void *src;
GL_EXTCALL(glBindBufferARB(GL_ARRAY_BUFFER_ARB, dest->vbo));
checkGLcall("glBindBufferARB");
src = GL_EXTCALL(glMapBufferARB(GL_ARRAY_BUFFER_ARB, GL_READ_ONLY_ARB));
@@ -4274,8 +4283,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
if ( ((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZ ) ||
((DestFVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) ) {
/* The position first */
float *p =
(float *) (((char *) lpStrideData->u.s.position.lpData) + i * lpStrideData->u.s.position.dwStride);
const float *p =
(const float *)(lpStrideData->u.s.position.lpData + i * lpStrideData->u.s.position.dwStride);
float x, y, z, rhw;
TRACE("In: ( %06.2f %06.2f %06.2f )\n", p[0], p[1], p[2]);
@@ -4390,8 +4399,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
if(dest_conv) dest_conv += sizeof(DWORD);
}
if (DestFVF & WINED3DFVF_NORMAL) {
float *normal =
(float *) (((float *) lpStrideData->u.s.normal.lpData) + i * lpStrideData->u.s.normal.dwStride);
const float *normal =
(const float *)(lpStrideData->u.s.normal.lpData + i * lpStrideData->u.s.normal.dwStride);
/* AFAIK this should go into the lighting information */
FIXME("Didn't expect the destination to have a normal\n");
copy_and_next(dest_ptr, normal, 3 * sizeof(float));
@@ -4401,8 +4410,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
}
if (DestFVF & WINED3DFVF_DIFFUSE) {
DWORD *color_d =
(DWORD *) (((char *) lpStrideData->u.s.diffuse.lpData) + i * lpStrideData->u.s.diffuse.dwStride);
const DWORD *color_d =
(const DWORD *)(lpStrideData->u.s.diffuse.lpData + i * lpStrideData->u.s.diffuse.dwStride);
if(!color_d) {
static BOOL warned = FALSE;
@@ -4432,8 +4441,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
if (DestFVF & WINED3DFVF_SPECULAR) {
/* What's the color value in the feedback buffer? */
DWORD *color_s =
(DWORD *) (((char *) lpStrideData->u.s.specular.lpData) + i * lpStrideData->u.s.specular.dwStride);
const DWORD *color_s =
(const DWORD *)(lpStrideData->u.s.specular.lpData + i * lpStrideData->u.s.specular.dwStride);
if(!color_s) {
static BOOL warned = FALSE;
@@ -4462,8 +4471,8 @@ process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIndex, DWORD dwCo
}
for (tex_index = 0; tex_index < numTextures; tex_index++) {
float *tex_coord =
(float *) (((char *) lpStrideData->u.s.texCoords[tex_index].lpData) +
const float *tex_coord =
(const float *)(lpStrideData->u.s.texCoords[tex_index].lpData +
i * lpStrideData->u.s.texCoords[tex_index].dwStride);
if(!tex_coord) {
ERR("No source texture, but destination requests one\n");
@@ -4901,25 +4910,29 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EndStateBlock(IWineD3DDevice *iface, IW
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if(object->changed.vertexShaderConstantsI[i]) {
if (object->changed.vertexShaderConstantsI & (1 << i))
{
object->contained_vs_consts_i[object->num_contained_vs_consts_i] = i;
object->num_contained_vs_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if(object->changed.vertexShaderConstantsB[i]) {
if (object->changed.vertexShaderConstantsB & (1 << i))
{
object->contained_vs_consts_b[object->num_contained_vs_consts_b] = i;
object->num_contained_vs_consts_b++;
}
}
for(i = 0; i < MAX_CONST_I; i++) {
if(object->changed.pixelShaderConstantsI[i]) {
if (object->changed.pixelShaderConstantsI & (1 << i))
{
object->contained_ps_consts_i[object->num_contained_ps_consts_i] = i;
object->num_contained_ps_consts_i++;
}
}
for(i = 0; i < MAX_CONST_B; i++) {
if(object->changed.pixelShaderConstantsB[i]) {
if (object->changed.pixelShaderConstantsB & (1 << i))
{
object->contained_ps_consts_b[object->num_contained_ps_consts_b] = i;
object->num_contained_ps_consts_b++;
}
@@ -5018,7 +5031,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa
unsigned int i;
WINED3DRECT curRect;
RECT vp_rect;
WINED3DVIEWPORT *vp = &This->stateBlock->viewport;
const WINED3DVIEWPORT *vp = &This->stateBlock->viewport;
UINT drawable_width, drawable_height;
IWineD3DSurfaceImpl *depth_stencil = (IWineD3DSurfaceImpl *) This->stencilBufferTarget;
IWineD3DSwapChainImpl *swapchain = NULL;
@@ -5131,7 +5144,7 @@ HRESULT IWineD3DDeviceImpl_ClearSurface(IWineD3DDeviceImpl *This, IWineD3DSurfa
/* Now process each rect in turn */
for (i = 0; i < Count; i++) {
/* Note gl uses lower left, width/height */
IntersectRect((RECT *) &curRect, &vp_rect, (RECT *) &pRects[i]);
IntersectRect((RECT *)&curRect, &vp_rect, (const RECT *)&pRects[i]);
if(This->stateBlock->renderState[WINED3DRS_SCISSORTESTENABLE]) {
IntersectRect((RECT *) &curRect, (RECT *) &curRect, &This->stateBlock->scissorRect);
}
@@ -5399,7 +5412,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveUP(IWineD3DDevice *
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData) {
static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided(IWineD3DDevice *iface,
WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
const WineDirect3DVertexStridedData *DrawPrimStrideData)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
/* Mark the state dirty until we have nicer tracking
@@ -5415,7 +5431,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_DrawPrimitiveStrided (IWineD3DDevice *i
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface, WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount, WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, CONST void *pIndexData, WINED3DFORMAT IndexDataFormat) {
static HRESULT WINAPI IWineD3DDeviceImpl_DrawIndexedPrimitiveStrided(IWineD3DDevice *iface,
WINED3DPRIMITIVETYPE PrimitiveType, UINT PrimitiveCount,
const WineDirect3DVertexStridedData *DrawPrimStrideData, UINT NumVertices, const void *pIndexData,
WINED3DFORMAT IndexDataFormat)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
DWORD idxSize = (IndexDataFormat == WINED3DFMT_INDEX32 ? 4 : 2);
@@ -5607,7 +5627,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetFrontBufferData(IWineD3DDevice *if
static HRESULT WINAPI IWineD3DDeviceImpl_ValidateDevice(IWineD3DDevice *iface, DWORD* pNumPasses) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DBaseTextureImpl *texture;
const GlPixelFormatDesc *gl_info;
const struct GlPixelFormatDesc *gl_info;
DWORD i;
TRACE("(%p) : %p\n", This, pNumPasses);
@@ -5759,10 +5779,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetCurrentTexturePalette(IWineD3DDevi
static HRESULT WINAPI IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DDevice *iface, BOOL bSoftware) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
static BOOL showFixmes = TRUE;
if (showFixmes) {
static BOOL warned;
if (!warned)
{
FIXME("(%p) : stub\n", This);
showFixmes = FALSE;
warned = TRUE;
}
This->softwareVertexProcessing = bSoftware;
@@ -5772,10 +5793,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetSoftwareVertexProcessing(IWineD3DD
static BOOL WINAPI IWineD3DDeviceImpl_GetSoftwareVertexProcessing(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
static BOOL showFixmes = TRUE;
if (showFixmes) {
static BOOL warned;
if (!warned)
{
FIXME("(%p) : stub\n", This);
showFixmes = FALSE;
warned = TRUE;
}
return This->softwareVertexProcessing;
}
@@ -5801,11 +5823,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetRasterStatus(IWineD3DDevice *iface
static HRESULT WINAPI IWineD3DDeviceImpl_SetNPatchMode(IWineD3DDevice *iface, float nSegments) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
static BOOL showfixmes = TRUE;
static BOOL warned;
if(nSegments != 0.0f) {
if( showfixmes) {
if (!warned)
{
FIXME("(%p) : stub nSegments(%f)\n", This, nSegments);
showfixmes = FALSE;
warned = TRUE;
}
}
return WINED3D_OK;
@@ -5813,10 +5836,11 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetNPatchMode(IWineD3DDevice *iface,
static float WINAPI IWineD3DDeviceImpl_GetNPatchMode(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
static BOOL showfixmes = TRUE;
if( showfixmes) {
static BOOL warned;
if (!warned)
{
FIXME("(%p) : stub returning(%f)\n", This, 0.0f);
showfixmes = FALSE;
warned = TRUE;
}
return 0.0f;
}
@@ -5875,7 +5899,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_UpdateSurface(IWineD3DDevice *iface,
return IWineD3DSurface_BltFast(pDestinationSurface,
pDestPoint ? pDestPoint->x : 0,
pDestPoint ? pDestPoint->y : 0,
pSourceSurface, (RECT *) pSourceRect, 0);
pSourceSurface, pSourceRect, 0);
}
if (destFormat == WINED3DFMT_UNKNOWN) {
@@ -6319,7 +6343,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_ColorFill(IWineD3DDevice *iface, IWineD
memset(&BltFx, 0, sizeof(BltFx));
BltFx.dwSize = sizeof(BltFx);
BltFx.u5.dwFillColor = argb_to_fmt(color, surface->resource.format);
return IWineD3DSurface_Blt(pSurface, (RECT *) pRect, NULL, NULL, WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_NONE);
return IWineD3DSurface_Blt(pSurface, (const RECT *)pRect, NULL, NULL,
WINEDDBLT_COLORFILL, &BltFx, WINED3DTEXF_NONE);
}
}
@@ -6443,7 +6468,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetDepthStencilSurface(IWineD3DDevice
}
void stretch_rect_fbo(IWineD3DDevice *iface, IWineD3DSurface *src_surface, WINED3DRECT *src_rect,
IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip) {
IWineD3DSurface *dst_surface, WINED3DRECT *dst_rect, const WINED3DTEXTUREFILTERTYPE filter, BOOL flip)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
GLbitfield mask = GL_COLOR_BUFFER_BIT; /* TODO: Support blitting depth/stencil surfaces */
IWineD3DSwapChain *src_swapchain, *dst_swapchain;
@@ -6736,7 +6762,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i
This->cursorHeight = pSur->currentDesc.Height;
if (SUCCEEDED(IWineD3DSurface_LockRect(pCursorBitmap, &rect, NULL, WINED3DLOCK_READONLY)))
{
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *tableEntry = getFormatDescEntry(WINED3DFMT_A8R8G8B8, &GLINFO_LOCATION, &glDesc);
char *mem, *bits = (char *)rect.pBits;
GLint intfmt = glDesc->glInternal;
@@ -6914,7 +6940,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice*
return WINED3D_OK;
}
static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, WINED3DPRESENT_PARAMETERS* pPresentationParameters) {
static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters)
{
IWineD3DDeviceImpl *This = surface->resource.wineD3DDevice; /* for GL_SUPPORT */
/* Reallocate proper memory for the front and back buffer and adjust their sizes */
@@ -6977,7 +7004,8 @@ static HRESULT WINAPI reset_unload_resources(IWineD3DResource *resource, void *d
return S_OK;
}
static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, WINED3DPRESENT_PARAMETERS *pp) {
static BOOL is_display_mode_supported(IWineD3DDeviceImpl *This, const WINED3DPRESENT_PARAMETERS *pp)
{
UINT i, count;
WINED3DDISPLAYMODE m;
HRESULT hr;
@@ -7291,7 +7319,7 @@ static void WINAPI IWineD3DDeviceImpl_SetGammaRamp(IWineD3DDevice * iface, UINT
TRACE("Relaying to swapchain\n");
if (IWineD3DDeviceImpl_GetSwapChain(iface, iSwapChain, &swapchain) == WINED3D_OK) {
IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, (WINED3DGAMMARAMP *)pRamp);
IWineD3DSwapChain_SetGammaRamp(swapchain, Flags, pRamp);
IWineD3DSwapChain_Release(swapchain);
}
return;
@@ -7318,14 +7346,14 @@ static void WINAPI IWineD3DDeviceImpl_GetGammaRamp(IWineD3DDevice *iface, UINT i
* any handles to other resource held by the caller must be closed
* (e.g. a texture should release all held surfaces because telling the device that it's been released.)
*****************************************************/
static void WINAPI IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){
static void IWineD3DDeviceImpl_AddResource(IWineD3DDevice *iface, IWineD3DResource *resource){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : Adding Resource %p\n", This, resource);
list_add_head(&This->resources, &((IWineD3DResourceImpl *) resource)->resource.resource_list_entry);
}
static void WINAPI IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){
static void IWineD3DDeviceImpl_RemoveResource(IWineD3DDevice *iface, IWineD3DResource *resource){
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
TRACE("(%p) : Removing resource %p\n", This, resource);
+228 -201
View File
@@ -154,20 +154,30 @@ static const shader_backend_t *select_shader_backend(UINT Adapter, WINED3DDEVTYP
static const struct blit_shader *select_blit_implementation(UINT Adapter, WINED3DDEVTYPE DeviceType);
/* lookup tables */
int minLookup[MAX_LOOKUPS];
int maxLookup[MAX_LOOKUPS];
DWORD *stateLookup[MAX_LOOKUPS];
DWORD minMipLookup[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
DWORD minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1] = {
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
{GL_NEAREST, GL_NEAREST, GL_NEAREST},
const int minLookup[MAX_LOOKUPS] =
{
WINED3DTADDRESS_WRAP, /* WINELOOKUP_WARPPARAM */
};
DWORD magLookup[WINED3DTEXF_ANISOTROPIC + 1];
DWORD magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] = {
const int maxLookup[MAX_LOOKUPS] =
{
WINED3DTADDRESS_MIRRORONCE, /* WINELOOKUP_WARPPARAM */
};
DWORD *stateLookup[MAX_LOOKUPS];
struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
{
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
{{GL_NEAREST, GL_NEAREST, GL_NEAREST}},
};
GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1] =
{
GL_NEAREST, GL_NEAREST, GL_NEAREST, GL_NEAREST
};
@@ -367,12 +377,8 @@ static ULONG WINAPI IWineD3DImpl_Release(IWineD3D *iface) {
/* Set the shader type for this device, depending on the given capabilities,
* the device type, and the user preferences in wined3d_settings */
void select_shader_mode(
WineD3D_GL_Info *gl_info,
WINED3DDEVTYPE DeviceType,
int* ps_selected,
int* vs_selected) {
static void select_shader_mode(const WineD3D_GL_Info *gl_info, WINED3DDEVTYPE DeviceType, int *ps_selected, int *vs_selected)
{
if (wined3d_settings.vs_mode == VS_NONE) {
*vs_selected = SHADER_NONE;
} else if (gl_info->supported[ARB_VERTEX_SHADER] && wined3d_settings.glslRequested) {
@@ -450,7 +456,8 @@ static void select_shader_max_constants(
**********************************************************/
#define GLINFO_LOCATION (*gl_info)
static inline BOOL test_arb_vs_offset_limit(WineD3D_GL_Info *gl_info) {
static inline BOOL test_arb_vs_offset_limit(const WineD3D_GL_Info *gl_info)
{
GLuint prog;
BOOL ret = FALSE;
const char *testcode =
@@ -494,7 +501,7 @@ static DWORD ver_for_ext(GL_SupportedExt ext)
return 0;
}
BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
const char *GL_Extensions = NULL;
const char *WGL_Extensions = NULL;
const char *gl_string = NULL;
@@ -1075,8 +1082,13 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
* shader capabilities, so we use the shader capabilities to distinguish between FX and 6xxx/7xxx.
*/
if(WINE_D3D9_CAPABLE(gl_info) && (gl_info->vs_nv_version == VS_VERSION_30)) {
/* Geforce GTX - highend */
if(strstr(gl_info->gl_renderer, "GTX 280")) {
gl_info->gl_card = CARD_NVIDIA_GEFORCE_GTX280;
vidmem = 1024;
}
/* Geforce9 - highend */
if(strstr(gl_info->gl_renderer, "9800")) {
else if(strstr(gl_info->gl_renderer, "9800")) {
gl_info->gl_card = CARD_NVIDIA_GEFORCE_9800GT;
vidmem = 512;
}
@@ -1336,11 +1348,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
else
gl_info->vidmem = WINE_DEFAULT_VIDMEM;
/* Load all the lookup tables
TODO: It may be a good idea to make minLookup and maxLookup const and populate them in wined3d_private.h where they are declared */
minLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_WRAP;
maxLookup[WINELOOKUP_WARPPARAM] = WINED3DTADDRESS_MIRRORONCE;
/* Load all the lookup tables */
for (i = 0; i < MAX_LOOKUPS; i++) {
stateLookup[i] = HeapAlloc(GetProcessHeap(), 0, sizeof(*stateLookup[i]) * (1 + maxLookup[i] - minLookup[i]) );
}
@@ -1363,19 +1371,21 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info) {
gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR : GL_NEAREST;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_POINT] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE][WINED3DTEXF_LINEAR] = GL_LINEAR;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_NONE] = GL_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_POINT][WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_LINEAR][WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_NONE] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ?
GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_POINT] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC][WINED3DTEXF_LINEAR] = gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_POINT] = GL_LINEAR;
minMipLookup[WINED3DTEXF_NONE].mip[WINED3DTEXF_LINEAR] = GL_LINEAR;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_NONE] = GL_NEAREST;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_POINT] = GL_NEAREST_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_POINT].mip[WINED3DTEXF_LINEAR] = GL_NEAREST_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_NONE] = GL_LINEAR;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_POINT] = GL_LINEAR_MIPMAP_NEAREST;
minMipLookup[WINED3DTEXF_LINEAR].mip[WINED3DTEXF_LINEAR] = GL_LINEAR_MIPMAP_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_NONE]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_POINT]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_NEAREST : GL_LINEAR;
minMipLookup[WINED3DTEXF_ANISOTROPIC].mip[WINED3DTEXF_LINEAR]
= gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC] ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR;
/* TODO: config lookups */
@@ -1527,7 +1537,7 @@ static HRESULT WINAPI IWineD3DImpl_EnumAdapterModes(IWineD3D *iface, UINT Adapte
if (Adapter == 0 && !DEBUG_SINGLE_MODE) { /* Display */
DEVMODEW DevModeW;
int ModeIdx = 0;
int i = 0;
UINT i = 0;
int j = 0;
ZeroMemory(&DevModeW, sizeof(DevModeW));
@@ -1665,6 +1675,18 @@ static HRESULT WINAPI IWineD3DImpl_GetAdapterIdentifier(IWineD3D *iface, UINT Ad
*(pIdentifier->Revision) = 0;
*pIdentifier->DeviceIdentifier = IID_D3DDEVICE_D3DUID;
if(wined3d_settings.pci_device_id != PCI_DEVICE_NONE)
{
TRACE_(d3d_caps)("Overriding pci device id with: %x\n", wined3d_settings.pci_device_id);
*(pIdentifier->DeviceId) = wined3d_settings.pci_device_id;
}
if(wined3d_settings.pci_vendor_id != PCI_VENDOR_NONE)
{
TRACE_(d3d_caps)("Overriding pci vendor id with: %x\n", wined3d_settings.pci_vendor_id);
*(pIdentifier->VendorId) = wined3d_settings.pci_vendor_id;
}
if (Flags & WINED3DENUM_NO_WHQL_LEVEL) {
*(pIdentifier->WHQLLevel) = 0;
} else {
@@ -1755,7 +1777,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDepthStencilMatch(IWineD3D *iface, UINT
WINED3DFORMAT DepthStencilFormat) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
int nCfgs;
WineD3D_PixelFormat *cfgs;
const WineD3D_PixelFormat *cfgs;
int it;
WARN_(d3d_caps)("(%p)-> (STUB) (Adptr:%d, DevType:(%x,%s), AdptFmt:(%x,%s), RendrTgtFmt:(%x,%s), DepthStencilFmt:(%x,%s))\n",
@@ -1790,7 +1812,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
BOOL Windowed, WINED3DMULTISAMPLE_TYPE MultiSampleType, DWORD* pQualityLevels) {
IWineD3DImpl *This = (IWineD3DImpl *)iface;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc;
TRACE_(d3d_caps)("(%p)-> (Adptr:%d, DevType:(%x,%s), SurfFmt:(%x,%s), Win?%d, MultiSamp:%x, pQual:%p)\n",
@@ -1823,7 +1845,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
if(glDesc->Flags & (WINED3DFMT_FLAG_DEPTH | WINED3DFMT_FLAG_STENCIL)) {
int i, nCfgs;
WineD3D_PixelFormat *cfgs;
const WineD3D_PixelFormat *cfgs;
cfgs = Adapters[Adapter].cfgs;
nCfgs = Adapters[Adapter].nCfgs;
@@ -1844,7 +1866,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceMultiSampleType(IWineD3D *iface, U
else if(glDesc->Flags & WINED3DFMT_FLAG_RENDERTARGET) {
short redSize, greenSize, blueSize, alphaSize, colorBits;
int i, nCfgs;
WineD3D_PixelFormat *cfgs;
const WineD3D_PixelFormat *cfgs;
if(!getColorBits(SurfaceFormat, &redSize, &greenSize, &blueSize, &alphaSize, &colorBits)) {
ERR("Unable to color bits for format %#x, can't check multisampling capability!\n", SurfaceFormat);
@@ -1965,7 +1987,7 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceType(IWineD3D *iface, UINT Adapter
static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat)
{
const struct fragment_pipeline *fp;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
switch(CheckFormat) {
case WINED3DFMT_V8U8:
@@ -1973,24 +1995,18 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_L6V5U5:
case WINED3DFMT_X8L8V8U8:
case WINED3DFMT_Q8W8V8U8:
/* Ask the fixed function pipeline implementation if it can deal
* with the conversion. If we've got a GL extension giving native
* support this will be an identity conversion. */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
/* We have a GL extension giving native support */
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
/* No native support: Ask the fixed function pipeline implementation if it
* can deal with the conversion
*/
fp = select_fragment_implementation(Adapter, DeviceType);
if(fp->conv_supported(CheckFormat)) {
if (fp->color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
} else {
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
}
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
default:
TRACE_(d3d_caps)("[FAILED]\n");
@@ -2002,7 +2018,7 @@ static BOOL CheckBumpMapCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayFormat, WINED3DFORMAT DepthStencilFormat)
{
int it=0;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(DepthStencilFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */
@@ -2028,7 +2044,7 @@ static BOOL CheckDepthStencilCapability(UINT Adapter, WINED3DFORMAT DisplayForma
static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
{
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */
@@ -2046,7 +2062,7 @@ static BOOL CheckFilterCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
static BOOL CheckRenderTargetCapability(WINED3DFORMAT AdapterFormat, WINED3DFORMAT CheckFormat)
{
UINT Adapter = 0;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */
@@ -2153,7 +2169,7 @@ static BOOL CheckSrgbWriteCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WI
/* Check if a format support blending in combination with pixel shaders */
static BOOL CheckPostPixelShaderBlendingCapability(UINT Adapter, WINED3DFORMAT CheckFormat)
{
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
const StaticPixelFormatDesc *desc = getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
/* Fail if we weren't able to get a description of the format */
@@ -2185,7 +2201,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
{
const shader_backend_t *shader_backend;
const struct fragment_pipeline *fp;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
switch (CheckFormat) {
@@ -2260,25 +2276,18 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_L6V5U5:
case WINED3DFMT_Q8W8V8U8:
case WINED3DFMT_V16U16:
case WINED3DFMT_W11V11U10:
/* Ask the shader backend if it can deal with the conversion. If
* we've got a GL extension giving native support this will be an
* identity conversion. */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
if(glDesc->conversion_group == WINED3DFMT_UNKNOWN) {
/* We have a GL extension giving native support */
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
/* No native support: Ask the fixed function pipeline implementation if it
* can deal with the conversion
*/
shader_backend = select_shader_backend(Adapter, DeviceType);
if(shader_backend->shader_conv_supported(CheckFormat)) {
if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
} else {
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
}
TRACE_(d3d_caps)("[FAILED]\n");
return FALSE;
case WINED3DFMT_DXT1:
case WINED3DFMT_DXT2:
@@ -2301,6 +2310,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
case WINED3DFMT_INDEX32:
case WINED3DFMT_Q16W16V16U16:
case WINED3DFMT_A2W10V10U10:
case WINED3DFMT_W11V11U10:
TRACE_(d3d_caps)("[FAILED]\n"); /* Enable when implemented */
return FALSE;
@@ -2383,10 +2393,12 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
/* Vendor specific formats */
case WINED3DFMT_ATI2N:
if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) {
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &glDesc);
shader_backend = select_shader_backend(Adapter, DeviceType);
fp = select_fragment_implementation(Adapter, DeviceType);
if(shader_backend->shader_conv_supported(CheckFormat) &&
fp->conv_supported(CheckFormat)) {
if (shader_backend->shader_color_fixup_supported(glDesc->color_fixup)
&& fp->color_fixup_supported(glDesc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
@@ -2419,6 +2431,7 @@ static BOOL CheckTextureCapability(UINT Adapter, WINED3DDEVTYPE DeviceType, WINE
}
static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WINED3DDEVTYPE DeviceType, WINED3DFORMAT CheckFormat, WINED3DSURFTYPE SurfaceType) {
const struct GlPixelFormatDesc *format_desc;
const struct blit_shader *blitter;
if(SurfaceType == SURFACE_GDI) {
@@ -2455,8 +2468,10 @@ static BOOL CheckSurfaceCapability(UINT Adapter, WINED3DFORMAT AdapterFormat, WI
if(CheckDepthStencilCapability(Adapter, AdapterFormat, CheckFormat)) return TRUE;
/* If opengl can't process the format natively, the blitter may be able to convert it */
getFormatDescEntry(CheckFormat, &GLINFO_LOCATION, &format_desc);
blitter = select_blit_implementation(Adapter, DeviceType);
if(blitter->conv_supported(CheckFormat)) {
if (blitter->color_fixup_supported(format_desc->color_fixup))
{
TRACE_(d3d_caps)("[OK]\n");
return TRUE;
}
@@ -3726,7 +3741,8 @@ ULONG WINAPI D3DCB_DefaultDestroyVolume(IWineD3DVolume *pVolume) {
return IUnknown_Release(volumeParent);
}
static BOOL implementation_is_apple(WineD3D_GL_Info *gl_info) {
static BOOL implementation_is_apple(const WineD3D_GL_Info *gl_info)
{
/* MacOS has various specialities in the extensions it advertises. Some have to be loaded from
* the opengl 1.2+ core, while other extensions are advertised, but software emulated. So try to
* detect the Apple OpenGL implementation to apply some extension fixups afterwards.
@@ -3848,6 +3864,7 @@ static const struct driver_version_information driver_version_table[] = {
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_8800GTS, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9600GT, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_9800GT, 7, 15, 11, 7341 },
{VENDOR_NVIDIA, CARD_NVIDIA_GEFORCE_GTX280, 7, 15, 11, 7341 },
/* ATI cards. The driver versions are somewhat similar, but not quite the same. Let's hardcode */
{VENDOR_ATI, CARD_ATI_RADEON_9500, 6, 14, 10, 6764 },
@@ -3964,12 +3981,14 @@ static void fixup_extensions(WineD3D_GL_Info *gl_info) {
}
}
static void WINE_GLAPI invalid_func(void *data) {
static void WINE_GLAPI invalid_func(const void *data)
{
ERR("Invalid vertex attribute function called\n");
DebugBreak();
}
static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) {
static void WINE_GLAPI invalid_texcoord_func(GLenum unit, const void *data)
{
ERR("Invalid texcoord function called\n");
DebugBreak();
}
@@ -3979,8 +3998,9 @@ static void WINE_GLAPI invalid_texcoord_func(GLenum unit, void * data) {
/* Helper functions for providing vertex data to opengl. The arrays are initialized based on
* the extension detection and are used in drawStridedSlow
*/
static void WINE_GLAPI position_d3dcolor(void *data) {
DWORD pos = *((DWORD *) data);
static void WINE_GLAPI position_d3dcolor(const void *data)
{
DWORD pos = *((const DWORD *)data);
FIXME("Add a test for fixed function position from d3dcolor type\n");
glVertex4s(D3DCOLOR_B_R(pos),
@@ -3988,8 +4008,10 @@ static void WINE_GLAPI position_d3dcolor(void *data) {
D3DCOLOR_B_B(pos),
D3DCOLOR_B_A(pos));
}
static void WINE_GLAPI position_float4(void *data) {
GLfloat *pos = (float *) data;
static void WINE_GLAPI position_float4(const void *data)
{
const GLfloat *pos = data;
if (pos[3] < eps && pos[3] > -eps)
glVertex3fv(pos);
@@ -4000,8 +4022,9 @@ static void WINE_GLAPI position_float4(void *data) {
}
}
static void WINE_GLAPI diffuse_d3dcolor(void *data) {
DWORD diffuseColor = *((DWORD *) data);
static void WINE_GLAPI diffuse_d3dcolor(const void *data)
{
DWORD diffuseColor = *((const DWORD *)data);
glColor4ub(D3DCOLOR_B_R(diffuseColor),
D3DCOLOR_B_G(diffuseColor),
@@ -4009,148 +4032,152 @@ static void WINE_GLAPI diffuse_d3dcolor(void *data) {
D3DCOLOR_B_A(diffuseColor));
}
static void WINE_GLAPI specular_d3dcolor(void *data) {
DWORD specularColor = *((DWORD *) data);
static void WINE_GLAPI specular_d3dcolor(const void *data)
{
DWORD specularColor = *((const DWORD *)data);
GL_EXTCALL(glSecondaryColor3ubEXT)(D3DCOLOR_B_R(specularColor),
D3DCOLOR_B_G(specularColor),
D3DCOLOR_B_B(specularColor));
}
static void WINE_GLAPI warn_no_specular_func(void *data) {
static void WINE_GLAPI warn_no_specular_func(const void *data)
{
WARN("GL_EXT_secondary_color not supported\n");
}
void fillGLAttribFuncs(WineD3D_GL_Info *gl_info) {
position_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glVertex3fv;
position_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) position_float4;
position_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) position_d3dcolor;
position_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4] = (void *) glVertex2sv;
position_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
static void fillGLAttribFuncs(const WineD3D_GL_Info *gl_info)
{
position_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glVertex3fv;
position_funcs[WINED3DDECLTYPE_FLOAT4] = position_float4;
position_funcs[WINED3DDECLTYPE_D3DCOLOR] = position_d3dcolor;
position_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4] = (glAttribFunc)glVertex2sv;
position_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
position_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
position_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
position_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
position_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glColor3fv;
diffuse_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glColor4fv;
diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) diffuse_d3dcolor;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) glColor4ubv;
diffuse_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) glColor4sv;
diffuse_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) glColor4usv;
diffuse_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glColor3fv;
diffuse_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glColor4fv;
diffuse_funcs[WINED3DDECLTYPE_D3DCOLOR] = diffuse_d3dcolor;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_UBYTE4N] = (glAttribFunc)glColor4ubv;
diffuse_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_SHORT4N] = (glAttribFunc)glColor4sv;
diffuse_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_USHORT4N] = (glAttribFunc)glColor4usv;
diffuse_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
diffuse_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
/* No 4 component entry points here */
specular_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) GL_EXTCALL(glSecondaryColor3fvEXT);
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT);
} else {
specular_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) warn_no_specular_func;
specular_funcs[WINED3DDECLTYPE_FLOAT3] = warn_no_specular_func;
}
specular_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT4] = invalid_func;
if(GL_SUPPORT(EXT_SECONDARY_COLOR)) {
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) specular_d3dcolor;
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = specular_d3dcolor;
} else {
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) warn_no_specular_func;
specular_funcs[WINED3DDECLTYPE_D3DCOLOR] = warn_no_specular_func;
}
specular_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
specular_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
specular_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
specular_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
/* Only 3 component entry points here. Test how others behave. Float4 normals are used
* by one of our tests, trying to pass it to the pixel shader, which fails on Windows.
*/
normal_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glNormal3fv;
normal_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glNormal3fv; /* Just ignore the 4th value */
normal_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT1] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glNormal3fv;
normal_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glNormal3fv; /* Just ignore the 4th value */
normal_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
normal_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
normal_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) GL_EXTCALL(glMultiTexCoord1fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) GL_EXTCALL(glMultiTexCoord2fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) GL_EXTCALL(glMultiTexCoord3fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) GL_EXTCALL(glMultiTexCoord4fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (void *) GL_EXTCALL(glMultiTexCoord2svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (void *) GL_EXTCALL(glMultiTexCoord4svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord1fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord3fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4fvARB);
multi_texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4svARB);
multi_texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_UDEC3] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_DEC3N] = invalid_texcoord_func;
if (GL_SUPPORT(NV_HALF_FLOAT))
{
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) GL_EXTCALL(glMultiTexCoord2hvNV);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) GL_EXTCALL(glMultiTexCoord4hvNV);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV);
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord4hvNV);
} else {
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_texcoord_func;
multi_texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_texcoord_func;
}
texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (void *) glTexCoord1fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (void *) glTexCoord2fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (void *) glTexCoord3fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (void *) glTexCoord4fv;
texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (void *) glTexCoord2sv;
texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (void *) glTexCoord4sv;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UDEC3] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_DEC3N] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT1] = (glAttribFunc)glTexCoord1fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT2] = (glAttribFunc)glTexCoord2fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT3] = (glAttribFunc)glTexCoord3fv;
texcoord_funcs[WINED3DDECLTYPE_FLOAT4] = (glAttribFunc)glTexCoord4fv;
texcoord_funcs[WINED3DDECLTYPE_D3DCOLOR] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2] = (glAttribFunc)glTexCoord2sv;
texcoord_funcs[WINED3DDECLTYPE_SHORT4] = (glAttribFunc)glTexCoord4sv;
texcoord_funcs[WINED3DDECLTYPE_UBYTE4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT2N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_SHORT4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT2N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_USHORT4N] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_UDEC3] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_DEC3N] = invalid_func;
if (GL_SUPPORT(NV_HALF_FLOAT))
{
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) GL_EXTCALL(glTexCoord2hvNV);
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) GL_EXTCALL(glTexCoord4hvNV);
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (glAttribFunc)GL_EXTCALL(glTexCoord2hvNV);
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (glAttribFunc)GL_EXTCALL(glTexCoord4hvNV);
} else {
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = (void *) invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_2] = invalid_func;
texcoord_funcs[WINED3DDECLTYPE_FLOAT16_4] = invalid_func;
}
}
+182 -175
View File
@@ -142,14 +142,14 @@ void primitiveDeclarationConvertToStridedData(
/* We need to deal with frequency data!*/
BYTE *data = NULL;
const BYTE *data = NULL;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DVertexDeclarationImpl* vertexDeclaration = (IWineD3DVertexDeclarationImpl *)This->stateBlock->vertexDecl;
int i;
WINED3DVERTEXELEMENT *element;
unsigned int i;
const WINED3DVERTEXELEMENT *element;
DWORD stride;
DWORD numPreloadStreams = This->stateBlock->streamIsUP ? 0 : vertexDeclaration->num_streams;
DWORD *streams = vertexDeclaration->streams;
const DWORD *streams = vertexDeclaration->streams;
/* Check for transformed vertices, disable vertex shader if present */
strided->u.s.position_transformed = vertexDeclaration->position_transformed;
@@ -164,7 +164,7 @@ void primitiveDeclarationConvertToStridedData(
unsigned int idx;
element = vertexDeclaration->pDeclarationWine + i;
TRACE("%p Element %p (%d of %d)\n", vertexDeclaration->pDeclarationWine,
TRACE("%p Element %p (%u of %u)\n", vertexDeclaration->pDeclarationWine,
element, i + 1, vertexDeclaration->declarationWNumElements - 1);
if (This->stateBlock->streamSource[element->Stream] == NULL)
@@ -286,21 +286,22 @@ static void drawStridedFast(IWineD3DDevice *iface,UINT numberOfVertices, GLenum
* Slower GL version which extracts info about each vertex in turn
*/
static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd,
UINT NumVertexes, GLenum glPrimType,
const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex) {
static void drawStridedSlow(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT NumVertexes,
GLenum glPrimType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
{
unsigned int textureNo = 0;
const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL;
LONG vx_index;
ULONG vx_index;
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
UINT *streamOffset = This->stateBlock->streamOffset;
const UINT *streamOffset = This->stateBlock->streamOffset;
long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex;
BOOL pixelShader = use_ps(This);
BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
BOOL specular_fog = FALSE;
UINT texture_stages = GL_LIMITS(texture_stages);
const BYTE *texCoords[WINED3DDP_MAXTEXCOORD];
const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL;
DWORD tex_mask = 0;
TRACE("Using slow vertex array code\n");
@@ -321,56 +322,92 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
return;
}
/* Adding the stream offset once is cheaper than doing it every iteration. Do not modify the strided data, it is a pointer
* to the strided Data in the device and might be needed intact on the next draw
*/
for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
if(sd->u.s.texCoords[textureNo].lpData) {
texCoords[textureNo] = sd->u.s.texCoords[textureNo].lpData + streamOffset[sd->u.s.texCoords[textureNo].streamNo];
} else {
texCoords[textureNo] = NULL;
}
}
if(sd->u.s.diffuse.lpData) {
diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
}
if(sd->u.s.specular.lpData) {
specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
}
if(sd->u.s.normal.lpData) {
normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
}
if(sd->u.s.position.lpData) {
position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
}
if(FIXME_ON(d3d_draw)) {
if(specular && This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position_transformed )&&
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
if(GL_SUPPORT(EXT_FOG_COORD) && sd->u.s.specular.dwType != WINED3DDECLTYPE_D3DCOLOR) {
FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
}
}
if(This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR) {
FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
}
}
/* Start drawing in GL */
VTRACE(("glBegin(%x)\n", glPrimType));
glBegin(glPrimType);
/* Default settings for data that is not passed */
if (sd->u.s.normal.lpData == NULL) {
glNormal3f(0, 0, 0);
if (sd->u.s.position.lpData) position = sd->u.s.position.lpData + streamOffset[sd->u.s.position.streamNo];
if (sd->u.s.normal.lpData) normal = sd->u.s.normal.lpData + streamOffset[sd->u.s.normal.streamNo];
else glNormal3f(0, 0, 0);
if (sd->u.s.diffuse.lpData) diffuse = sd->u.s.diffuse.lpData + streamOffset[sd->u.s.diffuse.streamNo];
else glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
if (This->activeContext->num_untracked_materials && sd->u.s.diffuse.dwType != WINED3DDECLTYPE_D3DCOLOR)
FIXME("Implement diffuse color tracking from %s\n", debug_d3ddecltype(sd->u.s.diffuse.dwType));
if (sd->u.s.specular.lpData)
{
specular = sd->u.s.specular.lpData + streamOffset[sd->u.s.specular.streamNo];
/* special case where the fog density is stored in the specular alpha channel */
if (This->stateBlock->renderState[WINED3DRS_FOGENABLE]
&& (This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE
|| sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4)
&& This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE)
{
if (GL_SUPPORT(EXT_FOG_COORD))
{
if (sd->u.s.specular.dwType == WINED3DDECLTYPE_D3DCOLOR) specular_fog = TRUE;
else FIXME("Implement fog coordinates from %s\n", debug_d3ddecltype(sd->u.s.specular.dwType));
}
else
{
static BOOL warned;
if (!warned)
{
/* TODO: Use the fog table code from old ddraw */
FIXME("Implement fog for transformed vertices in software\n");
warned = TRUE;
}
}
}
}
if(sd->u.s.diffuse.lpData == NULL) {
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
else if (GL_SUPPORT(EXT_SECONDARY_COLOR))
{
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
}
if(sd->u.s.specular.lpData == NULL) {
if (GL_SUPPORT(EXT_SECONDARY_COLOR)) {
GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0);
for (textureNo = 0; textureNo < texture_stages; ++textureNo)
{
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
int texture_idx = This->texUnitMap[textureNo];
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0)
{
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
continue;
}
if (!pixelShader && !This->stateBlock->textures[textureNo]) continue;
if (texture_idx == -1) continue;
if (coordIdx > 7)
{
TRACE("tex: %d - Skip tex coords, as being system generated\n", textureNo);
continue;
}
else if (coordIdx < 0)
{
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
continue;
}
if(sd->u.s.texCoords[coordIdx].lpData)
{
texCoords[coordIdx] =
sd->u.s.texCoords[coordIdx].lpData + streamOffset[sd->u.s.texCoords[coordIdx].streamNo];
tex_mask |= (1 << textureNo);
}
else
{
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
if (GL_SUPPORT(ARB_MULTITEXTURE))
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
else
glTexCoord4f(0, 0, 0, 1);
}
}
@@ -380,6 +417,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* For each primitive */
for (vx_index = 0; vx_index < NumVertexes; ++vx_index) {
UINT texture, tmp_tex_mask;
/* Blending data and Point sizes are not supported by this function. They are not supported by the fixed
* function pipeline at all. A Fixme for them is printed after decoding the vertex declaration
*/
@@ -389,63 +427,43 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* Indexed so work out the number of strides to skip */
if (idxSize == 2) {
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufS[startIdx+vx_index]));
VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufS[startIdx+vx_index]));
SkipnStrides = pIdxBufS[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
} else {
VTRACE(("Idx for vertex %d = %d\n", vx_index, pIdxBufL[startIdx+vx_index]));
VTRACE(("Idx for vertex %u = %u\n", vx_index, pIdxBufL[startIdx+vx_index]));
SkipnStrides = pIdxBufL[startIdx + vx_index] + This->stateBlock->loadBaseVertexIndex;
}
}
/* Texture coords --------------------------- */
for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) {
tmp_tex_mask = tex_mask;
for (texture = 0; tmp_tex_mask; tmp_tex_mask >>= 1, ++texture)
{
int coord_idx;
const void *ptr;
if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) {
FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n");
continue ;
if (!(tmp_tex_mask & 1)) continue;
coord_idx = This->stateBlock->textureState[texture][WINED3DTSS_TEXCOORDINDEX];
ptr = texCoords[coord_idx] + (SkipnStrides * sd->u.s.texCoords[coord_idx].dwStride);
if (GL_SUPPORT(ARB_MULTITEXTURE))
{
int texture_idx = This->texUnitMap[texture];
multi_texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](GL_TEXTURE0_ARB + texture_idx, ptr);
}
/* Query tex coords */
if (This->stateBlock->textures[textureNo] != NULL || pixelShader) {
int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX];
int texture_idx = This->texUnitMap[textureNo];
void *ptrToCoords;
if (coordIdx > 7) {
VTRACE(("tex: %d - Skip tex coords, as being system generated\n", textureNo));
continue;
} else if (coordIdx < 0) {
FIXME("tex: %d - Coord index %d is less than zero, expect a crash.\n", textureNo, coordIdx);
continue;
}
if (texture_idx == -1) continue;
if (texCoords[coordIdx] == NULL) {
TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo);
if (GL_SUPPORT(ARB_MULTITEXTURE)) {
GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1));
} else {
glTexCoord4f(0, 0, 0, 1);
}
continue;
}
ptrToCoords = texCoords[coordIdx] + (SkipnStrides * sd->u.s.texCoords[coordIdx].dwStride);
if (GL_SUPPORT(ARB_MULTITEXTURE))
multi_texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](GL_TEXTURE0_ARB + texture_idx, ptrToCoords);
else
texcoord_funcs[sd->u.s.texCoords[coordIdx].dwType](ptrToCoords);
else
{
texcoord_funcs[sd->u.s.texCoords[coord_idx].dwType](ptr);
}
} /* End of textures */
}
/* Diffuse -------------------------------- */
if (diffuse) {
DWORD *ptrToCoords = (DWORD *)(diffuse + (SkipnStrides * sd->u.s.diffuse.dwStride));
const void *ptrToCoords = diffuse + SkipnStrides * sd->u.s.diffuse.dwStride;
diffuse_funcs[sd->u.s.diffuse.dwType]((void *) ptrToCoords);
diffuse_funcs[sd->u.s.diffuse.dwType](ptrToCoords);
if(This->activeContext->num_untracked_materials) {
DWORD diffuseColor = ptrToCoords[0];
DWORD diffuseColor = ((const DWORD *)ptrToCoords)[0];
unsigned char i;
float color[4];
@@ -462,37 +480,26 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
/* Specular ------------------------------- */
if (specular) {
DWORD *ptrToCoords = (DWORD *)(specular + (SkipnStrides * sd->u.s.specular.dwStride));
const void *ptrToCoords = specular + SkipnStrides * sd->u.s.specular.dwStride;
/* special case where the fog density is stored in the specular alpha channel */
if(This->stateBlock->renderState[WINED3DRS_FOGENABLE] &&
(This->stateBlock->renderState[WINED3DRS_FOGVERTEXMODE] == WINED3DFOG_NONE || sd->u.s.position.dwType == WINED3DDECLTYPE_FLOAT4 )&&
This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) {
if(GL_SUPPORT(EXT_FOG_COORD)) {
DWORD specularColor = ptrToCoords[0];
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
} else {
static BOOL warned = FALSE;
if(!warned) {
/* TODO: Use the fog table code from old ddraw */
FIXME("Implement fog for transformed vertices in software\n");
warned = TRUE;
}
}
specular_funcs[sd->u.s.specular.dwType](ptrToCoords);
if (specular_fog)
{
DWORD specularColor = *(const DWORD *)ptrToCoords;
GL_EXTCALL(glFogCoordfEXT(specularColor >> 24));
}
specular_funcs[sd->u.s.specular.dwType]((void *) ptrToCoords);
}
/* Normal -------------------------------- */
if (normal != NULL) {
float *ptrToCoords = (float *)(normal + (SkipnStrides * sd->u.s.normal.dwStride));
const void *ptrToCoords = normal + SkipnStrides * sd->u.s.normal.dwStride;
normal_funcs[sd->u.s.normal.dwType](ptrToCoords);
}
/* Position -------------------------------- */
if (position) {
float *ptrToCoords = (float *)(position + (SkipnStrides * sd->u.s.position.dwStride));
const void *ptrToCoords = position + SkipnStrides * sd->u.s.position.dwStride;
position_funcs[sd->u.s.position.dwType](ptrToCoords);
}
@@ -509,16 +516,16 @@ static void drawStridedSlow(IWineD3DDevice *iface, WineDirect3DVertexStridedData
static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, const UINT index, const void *ptr) {
switch(type) {
case WINED3DDECLTYPE_FLOAT1:
GL_EXTCALL(glVertexAttrib1fvARB(index, (float *) ptr));
GL_EXTCALL(glVertexAttrib1fvARB(index, (const float *)ptr));
break;
case WINED3DDECLTYPE_FLOAT2:
GL_EXTCALL(glVertexAttrib2fvARB(index, (float *) ptr));
GL_EXTCALL(glVertexAttrib2fvARB(index, (const float *)ptr));
break;
case WINED3DDECLTYPE_FLOAT3:
GL_EXTCALL(glVertexAttrib3fvARB(index, (float *) ptr));
GL_EXTCALL(glVertexAttrib3fvARB(index, (const float *)ptr));
break;
case WINED3DDECLTYPE_FLOAT4:
GL_EXTCALL(glVertexAttrib4fvARB(index, (float *) ptr));
GL_EXTCALL(glVertexAttrib4fvARB(index, (const float *)ptr));
break;
case WINED3DDECLTYPE_UBYTE4:
@@ -530,29 +537,29 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
break;
case WINED3DDECLTYPE_SHORT2:
GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT4:
GL_EXTCALL(glVertexAttrib4svARB(index, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4svARB(index, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT2N:
{
GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NsvARB(index, s));
break;
}
case WINED3DDECLTYPE_USHORT2N:
{
GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NusvARB(index, s));
break;
}
case WINED3DDECLTYPE_SHORT4N:
GL_EXTCALL(glVertexAttrib4NsvARB(index, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4NsvARB(index, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_USHORT4N:
GL_EXTCALL(glVertexAttrib4NusvARB(index, (GLushort *) ptr));
GL_EXTCALL(glVertexAttrib4NusvARB(index, (const GLushort *)ptr));
break;
case WINED3DDECLTYPE_UDEC3:
@@ -569,21 +576,21 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
* byte float according to the IEEE standard
*/
if (GL_SUPPORT(NV_HALF_FLOAT)) {
GL_EXTCALL(glVertexAttrib2hvNV(index, (GLhalfNV *)ptr));
GL_EXTCALL(glVertexAttrib2hvNV(index, (const GLhalfNV *)ptr));
} else {
float x = float_16_to_32(((unsigned short *) ptr) + 0);
float y = float_16_to_32(((unsigned short *) ptr) + 1);
float x = float_16_to_32(((const unsigned short *)ptr) + 0);
float y = float_16_to_32(((const unsigned short *)ptr) + 1);
GL_EXTCALL(glVertexAttrib2fARB(index, x, y));
}
break;
case WINED3DDECLTYPE_FLOAT16_4:
if (GL_SUPPORT(NV_HALF_FLOAT)) {
GL_EXTCALL(glVertexAttrib4hvNV(index, (GLhalfNV *)ptr));
GL_EXTCALL(glVertexAttrib4hvNV(index, (const GLhalfNV *)ptr));
} else {
float x = float_16_to_32(((unsigned short *) ptr) + 0);
float y = float_16_to_32(((unsigned short *) ptr) + 1);
float z = float_16_to_32(((unsigned short *) ptr) + 2);
float w = float_16_to_32(((unsigned short *) ptr) + 3);
float x = float_16_to_32(((const unsigned short *)ptr) + 0);
float y = float_16_to_32(((const unsigned short *)ptr) + 1);
float z = float_16_to_32(((const unsigned short *)ptr) + 2);
float w = float_16_to_32(((const unsigned short *)ptr) + 3);
GL_EXTCALL(glVertexAttrib4fARB(index, x, y, z, w));
}
break;
@@ -595,18 +602,17 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, const DWORD type, co
}
}
static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx,
ULONG startVertex) {
static void drawStridedSlowVs(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex, ULONG startIdx, ULONG startVertex)
{
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
long SkipnStrides = startVertex + This->stateBlock->loadBaseVertexIndex;
const WORD *pIdxBufS = NULL;
const DWORD *pIdxBufL = NULL;
LONG vx_index;
ULONG vx_index;
int i;
IWineD3DStateBlockImpl *stateblock = This->stateBlock;
BYTE *ptr;
const BYTE *ptr;
if (idxSize != 0) {
/* Immediate mode drawing can't make use of indices in a vbo - get the data from the index buffer.
@@ -656,11 +662,12 @@ static void drawStridedSlowVs(IWineD3DDevice *iface, WineDirect3DVertexStridedDa
glEnd();
}
static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVertexStridedData *sd, UINT numberOfVertices,
GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
ULONG startIdx, ULONG startVertex) {
UINT numInstances = 0;
int numInstancedAttribs = 0, i, j;
static inline void drawStridedInstanced(IWineD3DDevice *iface, const WineDirect3DVertexStridedData *sd,
UINT numberOfVertices, GLenum glPrimitiveType, const void *idxData, short idxSize, ULONG minIndex,
ULONG startIdx, ULONG startVertex)
{
UINT numInstances = 0, i;
int numInstancedAttribs = 0, j;
UINT instancedData[sizeof(sd->u.input) / sizeof(sd->u.input[0]) /* 16 */];
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
IWineD3DStateBlockImpl *stateblock = This->stateBlock;
@@ -704,7 +711,7 @@ static inline void drawStridedInstanced(IWineD3DDevice *iface, WineDirect3DVerte
for(i = 0; i < numInstances; i++) {
/* Specify the instanced attributes using immediate mode calls */
for(j = 0; j < numInstancedAttribs; j++) {
BYTE *ptr = sd->u.input[instancedData[j]].lpData +
const BYTE *ptr = sd->u.input[instancedData[j]].lpData +
sd->u.input[instancedData[j]].dwStride * i +
stateblock->streamOffset[sd->u.input[instancedData[j]].streamNo];
if(sd->u.input[instancedData[j]].VBO) {
@@ -823,7 +830,7 @@ void drawPrimitive(IWineD3DDevice *iface,
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
IWineD3DSurfaceImpl *target;
int i;
unsigned int i;
if (NumPrimitives == 0) return;
@@ -854,7 +861,7 @@ void drawPrimitive(IWineD3DDevice *iface,
{
GLenum glPrimType;
BOOL emulation = FALSE;
WineDirect3DVertexStridedData *strided = &This->strided_streams;
const WineDirect3DVertexStridedData *strided = &This->strided_streams;
WineDirect3DVertexStridedData stridedlcl;
/* Ok, Work out which primitive is requested and how many vertexes that
will be */
@@ -865,10 +872,10 @@ void drawPrimitive(IWineD3DDevice *iface,
if(!use_vs(This)) {
if(!This->strided_streams.u.s.position_transformed && This->activeContext->num_untracked_materials &&
This->stateBlock->renderState[WINED3DRS_LIGHTING]) {
static BOOL first = TRUE;
if(first) {
static BOOL warned;
if (!warned) {
FIXME("Using software emulation because not all material properties could be tracked\n");
first = FALSE;
warned = TRUE;
} else {
TRACE("Using software emulation because not all material properties could be tracked\n");
}
@@ -878,10 +885,10 @@ void drawPrimitive(IWineD3DDevice *iface,
/* Either write a pipeline replacement shader or convert the specular alpha from unsigned byte
* to a float in the vertex buffer
*/
static BOOL first = TRUE;
if(first) {
static BOOL warned;
if (!warned) {
FIXME("Using software emulation because manual fog coordinates are provided\n");
first = FALSE;
warned = TRUE;
} else {
TRACE("Using software emulation because manual fog coordinates are provided\n");
}
@@ -898,10 +905,10 @@ void drawPrimitive(IWineD3DDevice *iface,
if (This->useDrawStridedSlow || emulation) {
/* Immediate mode drawing */
if(use_vs(This)) {
static BOOL first = TRUE;
if(first) {
static BOOL warned;
if (!warned) {
FIXME("Using immediate mode with vertex shaders for half float emulation\n");
first = FALSE;
warned = TRUE;
} else {
TRACE("Using immediate mode with vertex shaders for half float emulation\n");
}
@@ -1005,8 +1012,8 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
unsigned int i, j, num_quads, out_vertex_size, buffer_size, d3d_out_vertex_size;
float max_x = 0.0, max_y = 0.0, max_z = 0.0, neg_z = 0.0;
WineDirect3DVertexStridedData strided;
BYTE *data;
WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
const BYTE *data;
const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo;
DWORD vtxStride;
GLenum feedback_type;
GLfloat *feedbuffer;
@@ -1048,7 +1055,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
/* First, get the boundary cube of the input data */
for(j = 0; j < info->Height; j++) {
for(i = 0; i < info->Width; i++) {
float *v = (float *) (data + vtxStride * i + vtxStride * info->Stride * j);
const float *v = (const float *)(data + vtxStride * i + vtxStride * info->Stride * j);
if(fabs(v[0]) > max_x) max_x = fabs(v[0]);
if(fabs(v[1]) > max_y) max_y = fabs(v[1]);
if(fabs(v[2]) > max_z) max_z = fabs(v[2]);
@@ -1085,11 +1092,11 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
checkGLcall("glPolygonMode(GL_FRONT_AND_BACK, GL_FILL)");
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_FILLMODE));
if(patch->has_normals) {
float black[4] = {0, 0, 0, 0};
float red[4] = {1, 0, 0, 0};
float green[4] = {0, 1, 0, 0};
float blue[4] = {0, 0, 1, 0};
float white[4] = {1, 1, 1, 1};
const GLfloat black[4] = {0, 0, 0, 0};
const GLfloat red[4] = {1, 0, 0, 0};
const GLfloat green[4] = {0, 1, 0, 0};
const GLfloat blue[4] = {0, 0, 1, 0};
const GLfloat white[4] = {1, 1, 1, 1};
glEnable(GL_LIGHTING);
checkGLcall("glEnable(GL_LIGHTING)");
glLightModelfv(GL_LIGHT_MODEL_AMBIENT, black);
@@ -1172,13 +1179,13 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
glMap2f(GL_MAP2_VERTEX_3,
0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
(float *) data);
(const GLfloat *)data);
checkGLcall("glMap2f");
if(patch->has_texcoords) {
glMap2f(GL_MAP2_TEXTURE_COORD_4,
0, 1, vtxStride / sizeof(float), info->Width,
0, 1, info->Stride * vtxStride / sizeof(float), info->Height,
(float *) data);
(const GLfloat *)data);
checkGLcall("glMap2f");
}
glMapGrid2f(ceilf(patch->numSegs[0]), 0.0, 1.0, ceilf(patch->numSegs[1]), 0.0, 1.0);
@@ -1256,9 +1263,9 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This,
if(patch->has_normals) {
/* Now do the same with reverse light directions */
float x[4] = {-1, 0, 0, 0};
float y[4] = { 0, -1, 0, 0};
float z[4] = { 0, 0, -1, 0};
const GLfloat x[4] = {-1, 0, 0, 0};
const GLfloat y[4] = { 0, -1, 0, 0};
const GLfloat z[4] = { 0, 0, -1, 0};
glLightfv(GL_LIGHT0, GL_POSITION, x);
glLightfv(GL_LIGHT1, GL_POSITION, y);
glLightfv(GL_LIGHT2, GL_POSITION, z);
File diff suppressed because it is too large Load Diff
+10 -10
View File
@@ -74,7 +74,7 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
LEAVE_GL();
}
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@@ -84,31 +84,31 @@ static ULONG WINAPI IWineD3DIndexBufferImpl_Release(IWineD3DIndexBuffer *iface)
IWineD3DIndexBuffer IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetDevice(IWineD3DIndexBuffer *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DIndexBufferImpl_SetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetPrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DIndexBufferImpl_FreePrivateData(IWineD3DIndexBuffer *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DIndexBufferImpl_SetPriority(IWineD3DIndexBuffer *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DIndexBufferImpl_GetPriority(IWineD3DIndexBuffer *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DIndexBufferImpl_PreLoad(IWineD3DIndexBuffer *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
FIXME("iface %p stub!\n", iface);
}
static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
@@ -133,11 +133,11 @@ static void WINAPI IWineD3DIndexBufferImpl_UnLoad(IWineD3DIndexBuffer *iface) {
}
static WINED3DRESOURCETYPE WINAPI IWineD3DIndexBufferImpl_GetType(IWineD3DIndexBuffer *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
static HRESULT WINAPI IWineD3DIndexBufferImpl_GetParent(IWineD3DIndexBuffer *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
@@ -29,7 +29,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvts_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
BOOL bumpmap = FALSE;
if(stage > 0 && (stateblock->textureState[stage - 1][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE ||
@@ -548,7 +548,7 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3
}
}
void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD sampler = state - STATE_SAMPLER(0);
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler];
@@ -610,7 +610,8 @@ static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
}
}
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
{
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED |
WINED3DTEXOPCAPS_ADDSIGNED2X |
@@ -672,12 +673,26 @@ static void nvrc_fragment_free(IWineD3DDevice *iface) {}
* register combiners extension(Pre-GF3).
*/
static BOOL nvts_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
static BOOL nvts_color_fixup_supported(struct color_fixup_desc fixup)
{
if (TRACE_ON(d3d))
{
TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup);
}
/* We only support identity conversions. */
if (is_identity_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
}
const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
static const struct StateEntryTemplate nvrc_fragmentstate_template[] = {
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), nvrc_colorop }, 0 },
@@ -809,7 +824,7 @@ const struct fragment_pipeline nvts_fragment_pipeline = {
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
nvts_conv_supported,
nvts_color_fixup_supported,
nvrc_fragmentstate_template,
FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
};
@@ -819,7 +834,7 @@ const struct fragment_pipeline nvrc_fragment_pipeline = {
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
nvts_conv_supported,
nvts_color_fixup_supported,
nvrc_fragmentstate_template,
FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
};
+2 -1
View File
@@ -105,7 +105,8 @@ static HRESULT WINAPI IWineD3DPaletteImpl_GetEntries(IWineD3DPalette *iface, DW
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface, DWORD Flags, DWORD Start, DWORD Count, PALETTEENTRY *PalEnt)
static HRESULT WINAPI IWineD3DPaletteImpl_SetEntries(IWineD3DPalette *iface,
DWORD Flags, DWORD Start, DWORD Count, const PALETTEENTRY *PalEnt)
{
IWineD3DPaletteImpl *This = (IWineD3DPaletteImpl *)iface;
IWineD3DResourceImpl *res;
+97 -111
View File
@@ -272,32 +272,16 @@ static void pshader_set_limits(
/** Generate a pixel shader string using either GL_FRAGMENT_PROGRAM_ARB
or GLSL and send it to the card */
static inline VOID IWineD3DPixelShaderImpl_GenerateShader(
IWineD3DPixelShader *iface) {
IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface;
static inline GLuint IWineD3DPixelShaderImpl_GenerateShader(
IWineD3DPixelShaderImpl *This) {
SHADER_BUFFER buffer;
#if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders
it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */
if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) {
HeapFree(GetProcessHeap(), 0, This->fixupVertexBuffer);
This->fixupVertexBuffer = HeapAlloc(GetProcessHeap() , 0, SHADER_PGMSIZE);
This->fixupVertexBufferSize = PGMSIZE;
This->fixupVertexBuffer[0] = 0;
}
buffer.buffer = This->device->fixupVertexBuffer;
#else
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
#endif
buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE);
buffer.bsize = 0;
buffer.lineNo = 0;
buffer.newline = TRUE;
((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader(iface, &buffer);
#if 1 /* if were using the data buffer of device then we don't need to free it */
HeapFree(GetProcessHeap(), 0, buffer.buffer);
#endif
return ((IWineD3DDeviceImpl *)This->baseShader.device)->shader_backend->shader_generate_pshader((IWineD3DPixelShader *) This, &buffer);
}
static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *iface, CONST DWORD *pFunction) {
@@ -384,97 +368,18 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_SetFunction(IWineD3DPixelShader *i
return WINED3D_OK;
}
static HRESULT WINAPI IWineD3DPixelShaderImpl_CompileShader(IWineD3DPixelShader *iface) {
IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
static GLuint pixelshader_compile(IWineD3DPixelShaderImpl *This, const struct ps_compile_args *args)
{
CONST DWORD *function = This->baseShader.function;
UINT i, sampler;
IWineD3DBaseTextureImpl *texture;
HRESULT hr;
GLuint retval;
TRACE("(%p) : function %p\n", iface, function);
TRACE("(%p) : function %p\n", This, function);
/* We're already compiled, but check if any of the hardcoded stateblock assumptions
* changed.
*/
if (This->baseShader.is_compiled) {
char srgbenabled = deviceImpl->stateBlock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
for(i = 0; i < This->baseShader.num_sampled_samplers; i++) {
sampler = This->baseShader.sampled_samplers[i];
texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler];
if(texture && texture->baseTexture.shader_conversion_group != This->baseShader.sampled_format[sampler]) {
WARN("Recompiling shader %p due to format change on sampler %d\n", This, sampler);
WARN("Old format group %s, new is %s\n",
debug_d3dformat(This->baseShader.sampled_format[sampler]),
debug_d3dformat(texture->baseTexture.shader_conversion_group));
goto recompile;
}
}
/* TODO: Check projected textures */
/* TODO: Check texture types(2D, Cube, 3D) */
if(srgbenabled != This->srgb_enabled && This->srgb_mode_hardcoded) {
WARN("Recompiling shader because srgb correction is different and hardcoded\n");
goto recompile;
}
if(This->baseShader.reg_maps.vpos && !This->vpos_uniform) {
if(This->render_offscreen != deviceImpl->render_offscreen ||
This->height != ((IWineD3DSurfaceImpl *) deviceImpl->render_targets[0])->currentDesc.Height) {
WARN("Recompiling shader because vpos is used, hard compiled and changed\n");
goto recompile;
}
}
if(This->baseShader.reg_maps.usesdsy && !This->vpos_uniform) {
if(This->render_offscreen ? 0 : 1 != deviceImpl->render_offscreen ? 0 : 1) {
WARN("Recompiling shader because dsy is used, hard compiled and render_offscreen changed\n");
goto recompile;
}
}
if(This->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
if(((IWineD3DDeviceImpl *) This->baseShader.device)->strided_streams.u.s.position_transformed) {
if(This->vertexprocessing != pretransformed) {
WARN("Recompiling shader because pretransformed vertices are provided, which wasn't the case before\n");
goto recompile;
}
} else if(!use_vs((IWineD3DDeviceImpl *) This->baseShader.device) &&
This->vertexprocessing != fixedfunction) {
WARN("Recompiling shader because fixed function vp is in use, which wasn't the case before\n");
goto recompile;
} else if(This->vertexprocessing != vertexshader) {
WARN("Recompiling shader because vertex shaders are in use, which wasn't the case before\n");
goto recompile;
}
}
return WINED3D_OK;
recompile:
if(This->baseShader.recompile_count > 50) {
FIXME("Shader %p recompiled more than 50 times\n", This);
} else {
This->baseShader.recompile_count++;
}
deviceImpl->shader_backend->shader_destroy((IWineD3DBaseShader *) iface);
}
/* We don't need to compile */
if (!function) {
This->baseShader.is_compiled = TRUE;
return WINED3D_OK;
}
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1) {
shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
HRESULT hr;
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
memset(reg_maps, 0, sizeof(shader_reg_maps));
hr = shader_get_registers_used((IWineD3DBaseShader*)This, reg_maps,
This->semantics_in, NULL, This->baseShader.function, deviceImpl->stateBlock);
if (FAILED(hr)) return hr;
/* FIXME: validate reg_maps against OpenGL */
hr = IWineD3DPixelShader_UpdateSamplers((IWineD3DPixelShader *) This);
if(FAILED(hr)) {
ERR("Failed to update sampler information\n");
return 0;
}
/* Reset fields tracking stateblock values being hardcoded in the shader */
@@ -482,11 +387,30 @@ static HRESULT WINAPI IWineD3DPixelShaderImpl_CompileShader(IWineD3DPixelShader
/* Generate the HW shader */
TRACE("(%p) : Generating hardware program\n", This);
IWineD3DPixelShaderImpl_GenerateShader(iface);
retval = IWineD3DPixelShaderImpl_GenerateShader(This);
This->baseShader.is_compiled = TRUE;
return WINED3D_OK;
return retval;
}
static HRESULT WINAPI IWineD3DPixelShaderImpl_UpdateSamplers(IWineD3DPixelShader *iface) {
IWineD3DPixelShaderImpl *This =(IWineD3DPixelShaderImpl *)iface;
if (WINED3DSHADER_VERSION_MAJOR(This->baseShader.hex_version) == 1) {
IWineD3DDeviceImpl *deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
shader_reg_maps *reg_maps = &This->baseShader.reg_maps;
HRESULT hr;
/* Second pass: figure out which registers are used, what the semantics are, etc.. */
memset(reg_maps, 0, sizeof(shader_reg_maps));
hr = shader_get_registers_used((IWineD3DBaseShader*)This, reg_maps,
This->semantics_in, NULL, This->baseShader.function, deviceImpl->stateBlock);
return hr;
/* FIXME: validate reg_maps against OpenGL */
} else {
return WINED3D_OK;
}
}
const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
@@ -499,8 +423,70 @@ const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl =
IWineD3DPixelShaderImpl_GetParent,
/*** IWineD3DBaseShader methods ***/
IWineD3DPixelShaderImpl_SetFunction,
IWineD3DPixelShaderImpl_CompileShader,
/*** IWineD3DPixelShader methods ***/
IWineD3DPixelShaderImpl_UpdateSamplers,
IWineD3DPixelShaderImpl_GetDevice,
IWineD3DPixelShaderImpl_GetFunction
};
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args) {
UINT i, sampler;
IWineD3DBaseTextureImpl *tex;
args->srgb_correction = stateblock->renderState[WINED3DRS_SRGBWRITEENABLE] ? 1 : 0;
memset(args->color_fixup, 0, sizeof(args->color_fixup));
for(i = 0; i < shader->baseShader.num_sampled_samplers; i++) {
sampler = shader->baseShader.sampled_samplers[i];
tex = (IWineD3DBaseTextureImpl *) stateblock->textures[sampler];
if(!tex) {
args->color_fixup[sampler] = COLOR_FIXUP_IDENTITY;
continue;
}
args->color_fixup[sampler] = tex->baseTexture.shader_color_fixup;
}
if(shader->baseShader.hex_version >= WINED3DPS_VERSION(3,0)) {
if(((IWineD3DDeviceImpl *) shader->baseShader.device)->strided_streams.u.s.position_transformed) {
args->vp_mode = pretransformed;
} else if(use_vs((IWineD3DDeviceImpl *) shader->baseShader.device)) {
args->vp_mode = vertexshader;
} else {
args->vp_mode = fixedfunction;
}
} else {
args->vp_mode = vertexshader;
}
}
GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args)
{
UINT i;
struct ps_compiled_shader *old_array;
/* Usually we have very few GL shaders for each d3d shader(just 1 or maybe 2),
* so a linear search is more performant than a hashmap
*/
for(i = 0; i < shader->num_gl_shaders; i++) {
if(memcmp(&shader->gl_shaders[i].args, args, sizeof(*args)) == 0) {
return shader->gl_shaders[i].prgId;
}
}
TRACE("No matching GL shader found, compiling a new shader\n");
old_array = shader->gl_shaders;
if(old_array) {
shader->gl_shaders = HeapReAlloc(GetProcessHeap(), 0, old_array,
(shader->num_gl_shaders + 1) * sizeof(*shader->gl_shaders));
} else {
shader->gl_shaders = HeapAlloc(GetProcessHeap(), 0, sizeof(*shader->gl_shaders));
}
if(!shader->gl_shaders) {
ERR("Out of memory\n");
return 0;
}
shader->gl_shaders[shader->num_gl_shaders].args = *args;
shader->gl_shaders[shader->num_gl_shaders].prgId = pixelshader_compile(shader, args);
return shader->gl_shaders[shader->num_gl_shaders++].prgId;
}
+24 -89
View File
@@ -27,42 +27,8 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
/* IWineD3DResource IUnknown parts follow: */
HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, LPVOID *ppobj)
void resource_cleanup(IWineD3DResource *iface)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p)->(%s,%p)\n",This,debugstr_guid(riid),ppobj);
if (IsEqualGUID(riid, &IID_IUnknown)
|| IsEqualGUID(riid, &IID_IWineD3DBase)
|| IsEqualGUID(riid, &IID_IWineD3DResource)) {
IUnknown_AddRef(iface);
*ppobj = This;
return S_OK;
}
*ppobj = NULL;
return E_NOINTERFACE;
}
ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
ULONG ref = InterlockedIncrement(&This->resource.ref);
TRACE("(%p) : AddRef increasing from %d\n", This, ref - 1);
return ref;
}
ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
if (ref == 0) {
IWineD3DResourceImpl_CleanUp(iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
}
/* class static (not in vtable) */
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
struct list *e1, *e2;
PrivateData *data;
@@ -76,7 +42,7 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
LIST_FOR_EACH_SAFE(e1, e2, &This->resource.privateData) {
data = LIST_ENTRY(e1, PrivateData, entry);
hr = IWineD3DResourceImpl_FreePrivateData(iface, &data->tag);
hr = resource_free_private_data(iface, &data->tag);
if(hr != WINED3D_OK) {
ERR("Failed to free private data when destroying resource %p, hr = %08x\n", This, hr);
}
@@ -92,8 +58,8 @@ void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
return;
}
/* IWineD3DResource Interface follows: */
HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice** ppDevice) {
HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice** ppDevice)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %p\n", This, This->resource.wineD3DDevice);
*ppDevice = (IWineD3DDevice *) This->resource.wineD3DDevice;
@@ -101,8 +67,7 @@ HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DD
return WINED3D_OK;
}
static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *This,
REFGUID tag)
static PrivateData* resource_find_private_data(IWineD3DResourceImpl *This, REFGUID tag)
{
PrivateData *data;
struct list *entry;
@@ -120,21 +85,21 @@ static PrivateData* IWineD3DResourceImpl_FindPrivateData(IWineD3DResourceImpl *T
return NULL;
}
HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID refguid,
const void *pData, DWORD SizeOfData, DWORD Flags)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
TRACE("(%p) : %s %p %d %d\n", This, debugstr_guid(refguid), pData, SizeOfData, Flags);
IWineD3DResourceImpl_FreePrivateData(iface, refguid);
resource_free_private_data(iface, refguid);
data = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*data));
if (NULL == data) return E_OUTOFMEMORY;
data->tag = *refguid;
data->flags = Flags;
#if 0
(*data)->uniquenessValue = This->uniquenessValue;
#endif
if (Flags & WINED3DSPD_IUNKNOWN) {
if(SizeOfData != sizeof(IUnknown *)) {
WARN("IUnknown data with size %d, returning WINED3DERR_INVALIDCALL\n", SizeOfData);
@@ -160,20 +125,15 @@ HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFG
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID refguid, void *pData, DWORD *pSizeOfData)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
TRACE("(%p) : %p %p %p\n", This, refguid, pData, pSizeOfData);
data = IWineD3DResourceImpl_FindPrivateData(This, refguid);
data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND;
#if 0 /* This may not be right. */
if (((*data)->flags & WINED3DSPD_VOLATILE)
&& (*data)->uniquenessValue != This->uniquenessValue)
return DDERR_EXPIRED;
#endif
if (*pSizeOfData < data->size) {
*pSizeOfData = data->size;
return WINED3DERR_MOREDATA;
@@ -195,12 +155,13 @@ HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFG
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid) {
HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID refguid)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
PrivateData *data;
TRACE("(%p) : %s\n", This, debugstr_guid(refguid));
data = IWineD3DResourceImpl_FindPrivateData(This, refguid);
data = resource_find_private_data(This, refguid);
if (data == NULL) return WINED3DERR_NOTFOUND;
if (data->flags & WINED3DSPD_IUNKNOWN)
@@ -217,7 +178,8 @@ HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REF
return WINED3D_OK;
}
DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew) {
DWORD resource_set_priority(IWineD3DResource *iface, DWORD PriorityNew)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
DWORD PriorityOld = This->resource.priority;
This->resource.priority = PriorityNew;
@@ -225,30 +187,22 @@ DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface,
return PriorityOld;
}
DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface) {
DWORD resource_get_priority(IWineD3DResource *iface)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.priority );
return This->resource.priority;
}
/* Preloading of resources is not supported yet */
void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
FIXME("(%p) : stub\n", This);
}
void WINAPI IWineD3DResourceImpl_UnLoad(IWineD3DResource *iface) {
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
FIXME("(%p) : stub\n", This);
}
WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface) {
WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) : returning %d\n", This, This->resource.resourceType);
return This->resource.resourceType;
}
HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent) {
HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **pParent)
{
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
IUnknown_AddRef(This->resource.parent);
*pParent = This->resource.parent;
@@ -262,22 +216,3 @@ void dumpResources(struct list *list) {
FIXME("Leftover resource %p with type %d,%s\n", resource, IWineD3DResource_GetType((IWineD3DResource *) resource), debug_d3dresourcetype(IWineD3DResource_GetType((IWineD3DResource *) resource)));
}
}
static const IWineD3DResourceVtbl IWineD3DResource_Vtbl =
{
/* IUnknown */
IWineD3DResourceImpl_QueryInterface,
IWineD3DResourceImpl_AddRef,
IWineD3DResourceImpl_Release,
/* IWineD3DResource */
IWineD3DResourceImpl_GetParent,
IWineD3DResourceImpl_GetDevice,
IWineD3DResourceImpl_SetPrivateData,
IWineD3DResourceImpl_GetPrivateData,
IWineD3DResourceImpl_FreePrivateData,
IWineD3DResourceImpl_SetPriority,
IWineD3DResourceImpl_GetPriority,
IWineD3DResourceImpl_PreLoad,
IWineD3DResourceImpl_UnLoad,
IWineD3DResourceImpl_GetType
};
+135 -105
View File
@@ -244,7 +244,7 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
if (stateblock->renderState[WINED3DRS_ALPHABLENDENABLE] ||
stateblock->renderState[WINED3DRS_EDGEANTIALIAS] ||
stateblock->renderState[WINED3DRS_ANTIALIASEDLINEENABLE]) {
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(target->resource.format, &GLINFO_LOCATION, &glDesc);
/* Disable blending in all cases even without pixelshaders. With blending on we could face a big performance penalty.
@@ -702,7 +702,7 @@ state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCon
checkGLcall("glFinalCombinerInputNV()");
}
} else {
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const GLfloat black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
/* for the case of enabled lighting: */
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
@@ -1224,7 +1224,7 @@ static void state_fogdensity(DWORD state, IWineD3DStateBlockImpl *stateblock, Wi
static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
GLenum Parm = 0;
WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
const WineDirect3DStridedData *diffuse = &device->strided_streams.u.s.diffuse;
BOOL isDiffuseSupplied;
/* Depends on the decoded vertex declaration to read the existence of diffuse data.
@@ -1323,7 +1323,7 @@ static void state_colormat(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*)&device->updateStateBlock->material.Specular);
checkGLcall("glMaterialfv");
} else {
float black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
const GLfloat black[4] = {0.0f, 0.0f, 0.0f, 0.0f};
glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, &black[0]);
checkGLcall("glMaterialfv");
}
@@ -1566,10 +1566,10 @@ static void state_lastpixel(DWORD state, IWineD3DStateBlockImpl *stateblock, Win
if(stateblock->renderState[WINED3DRS_LASTPIXEL]) {
TRACE("Last Pixel Drawing Enabled\n");
} else {
static BOOL first = TRUE;
if(first) {
static BOOL warned;
if (!warned) {
FIXME("Last Pixel Drawing Disabled, not handled yet\n");
first = FALSE;
warned = TRUE;
} else {
TRACE("Last Pixel Drawing Disabled, not handled yet\n");
}
@@ -3119,8 +3119,9 @@ static void unloadTexCoords(IWineD3DStateBlockImpl *stateblock) {
}
}
static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd, GLint *curVBO) {
UINT *offset = stateblock->streamOffset;
static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, const WineDirect3DVertexStridedData *sd, GLint *curVBO)
{
const UINT *offset = stateblock->streamOffset;
unsigned int mapped_stage = 0;
unsigned int textureNo = 0;
@@ -3174,6 +3175,10 @@ static void loadTexCoords(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertex
static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / WINED3D_HIGHEST_TEXTURE_STATE;
DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage];
const GLfloat s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
const GLfloat t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
const GLfloat r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
const GLfloat q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
if (mapped_stage == -1) {
TRACE("No texture unit mapped to stage %d. Skipping texture coordinates.\n", stage);
@@ -3223,10 +3228,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
* equates roughly to EYE_LINEAR
*/
{
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
TRACE("WINED3DTSS_TCI_CAMERASPACEPOSITION - Set eye plane\n");
glMatrixMode(GL_MODELVIEW);
@@ -3257,10 +3258,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
case WINED3DTSS_TCI_CAMERASPACENORMAL:
{
if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
TRACE("WINED3DTSS_TCI_CAMERASPACENORMAL - Set eye plane\n");
glMatrixMode(GL_MODELVIEW);
@@ -3291,10 +3288,6 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR:
{
if (GL_SUPPORT(NV_TEXGEN_REFLECTION)) {
float s_plane[] = { 1.0, 0.0, 0.0, 0.0 };
float t_plane[] = { 0.0, 1.0, 0.0, 0.0 };
float r_plane[] = { 0.0, 0.0, 1.0, 0.0 };
float q_plane[] = { 0.0, 0.0, 0.0, 1.0 };
TRACE("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR - Set eye plane\n");
glMatrixMode(GL_MODELVIEW);
@@ -3480,7 +3473,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
}
}
void apply_pshader_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
static void apply_pshader_fog(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
IWineD3DDeviceImpl *device = stateblock->wineD3DDevice;
if (use_ps(device)) {
@@ -3518,9 +3511,6 @@ void apply_pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DC
* if a different texture was bound. I don't have to do anything.
*/
}
/* Compile and bind the shader */
IWineD3DPixelShader_CompileShader(stateblock->pixelShader);
} else {
/* Disabled the pixel shader - color ops weren't applied
* while it was enabled, so re-apply them.
@@ -3637,12 +3627,12 @@ static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, W
*/
if(stateblock->wineD3DDevice->view_ident) {
glLoadMatrixf(&stateblock->transforms[WINED3DTS_WORLDMATRIX(matrix)].u.m[0][0]);
checkGLcall("glLoadMatrixf")
checkGLcall("glLoadMatrixf");
} else {
glLoadMatrixf(&stateblock->transforms[WINED3DTS_VIEW].u.m[0][0]);
checkGLcall("glLoadMatrixf")
checkGLcall("glLoadMatrixf");
glMultMatrixf(&stateblock->transforms[WINED3DTS_WORLDMATRIX(matrix)].u.m[0][0]);
checkGLcall("glMultMatrixf")
checkGLcall("glMultMatrixf");
}
}
@@ -3716,7 +3706,7 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, Wine
* NOTE2: Apparently texture transforms do NOT need reapplying
*/
PLIGHTINFOEL *light = NULL;
const PLIGHTINFOEL *light = NULL;
glMatrixMode(GL_MODELVIEW);
checkGLcall("glMatrixMode(GL_MODELVIEW)");
@@ -3907,10 +3897,27 @@ static inline void unloadVertexData(IWineD3DStateBlockImpl *stateblock) {
unloadTexCoords(stateblock);
}
static inline void unload_numbered_array(IWineD3DStateBlockImpl *stateblock, WineD3DContext *context, int i)
{
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
checkGLcall("glDisableVertexAttribArrayARB(reg)");
/* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
* deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
* Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
* important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
* keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2: Episode Two.
*/
GL_EXTCALL(glVertexAttrib4NubARB(i, 0, 0, 0, 0));
checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
context->numbered_array_mask &= ~(1 << i);
}
/* This should match any arrays loaded in loadNumberedArrays
* TODO: Only load / unload arrays if we have to.
*/
static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineD3DContext *context)
{
/* disable any attribs (this is the same for both GLSL and ARB modes) */
GLint maxAttribs = 16;
int i;
@@ -3921,23 +3928,16 @@ static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock) {
if (glGetError() != GL_NO_ERROR)
maxAttribs = 16;
for (i = 0; i < maxAttribs; ++i) {
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
checkGLcall("glDisableVertexAttribArrayARB(reg)");
/* Some Windows drivers(NV GF 7) use the latest value that was used when drawing with the now
* deactivated stream disabled, some other drivers(ATI, NV GF 8) set the undefined values to 0x00.
* Let's set them to 0x00 to avoid hitting some undefined aspects of OpenGL. All that is really
* important here is the glDisableVertexAttribArrayARB call above. The test shows that the refrast
* keeps dereferencing the pointers, which would cause crashes in some games like Half Life 2: Episode Two.
*/
GL_EXTCALL(glVertexAttrib4NubARB(i, 0, 0, 0, 0));
checkGLcall("glVertexAttrib4NubARB(i, 0, 0, 0, 0)");
unload_numbered_array(stateblock, context, i);
}
}
static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *strided) {
static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock,
const WineDirect3DVertexStridedData *strided, WineD3DContext *context)
{
GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
int i;
UINT *offset = stateblock->streamOffset;
const UINT *offset = stateblock->streamOffset;
IWineD3DVertexBufferImpl *vb;
DWORD_PTR shift_index;
@@ -3945,13 +3945,15 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
stateblock->wineD3DDevice->instancedDraw = FALSE;
for (i = 0; i < MAX_ATTRIBS; i++) {
if (!strided->u.input[i].lpData && !strided->u.input[i].VBO)
if (!strided->u.input[i].VBO && !strided->u.input[i].lpData)
{
if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
continue;
}
/* Do not load instance data. It will be specified using glTexCoord by drawprim */
if(stateblock->streamFlags[strided->u.input[i].streamNo] & WINED3DSTREAMSOURCE_INSTANCEDATA) {
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
stateblock->wineD3DDevice->instancedDraw = TRUE;
continue;
}
@@ -3996,31 +3998,37 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
strided->u.input[i].lpData +
stateblock->loadBaseVertexIndex * strided->u.input[i].dwStride +
offset[strided->u.input[i].streamNo]) );
}
GL_EXTCALL(glEnableVertexAttribArrayARB(i));
}
if (!(context->numbered_array_mask & (1 << i)))
{
GL_EXTCALL(glEnableVertexAttribArrayARB(i));
context->numbered_array_mask |= (1 << i);
}
} else {
/* Stride = 0 means always the same values. glVertexAttribPointerARB doesn't do that. Instead disable the pointer and
* set up the attribute statically. But we have to figure out the system memory address.
*/
BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo];
const BYTE *ptr = strided->u.input[i].lpData + offset[strided->u.input[i].streamNo];
if(strided->u.input[i].VBO) {
vb = (IWineD3DVertexBufferImpl *) stateblock->streamSource[strided->u.input[i].streamNo];
ptr += (long) vb->resource.allocatedMemory;
}
GL_EXTCALL(glDisableVertexAttribArrayARB(i));
if (context->numbered_array_mask & (1 << i)) unload_numbered_array(stateblock, context, i);
switch(strided->u.input[i].dwType) {
case WINED3DDECLTYPE_FLOAT1:
GL_EXTCALL(glVertexAttrib1fvARB(i, (float *) ptr));
GL_EXTCALL(glVertexAttrib1fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT2:
GL_EXTCALL(glVertexAttrib2fvARB(i, (float *) ptr));
GL_EXTCALL(glVertexAttrib2fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT3:
GL_EXTCALL(glVertexAttrib3fvARB(i, (float *) ptr));
GL_EXTCALL(glVertexAttrib3fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_FLOAT4:
GL_EXTCALL(glVertexAttrib4fvARB(i, (float *) ptr));
GL_EXTCALL(glVertexAttrib4fvARB(i, (const GLfloat *)ptr));
break;
case WINED3DDECLTYPE_UBYTE4:
@@ -4032,38 +4040,38 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
break;
case WINED3DDECLTYPE_SHORT2:
GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT4:
GL_EXTCALL(glVertexAttrib4svARB(i, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4svARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_SHORT2N:
{
GLshort s[4] = {((short *) ptr)[0], ((short *) ptr)[1], 0, 1};
const GLshort s[4] = {((const GLshort *)ptr)[0], ((const GLshort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NsvARB(i, s));
break;
}
case WINED3DDECLTYPE_USHORT2N:
{
GLushort s[4] = {((unsigned short *) ptr)[0], ((unsigned short *) ptr)[1], 0, 1};
const GLushort s[4] = {((const GLushort *)ptr)[0], ((const GLushort *)ptr)[1], 0, 1};
GL_EXTCALL(glVertexAttrib4NusvARB(i, s));
break;
}
case WINED3DDECLTYPE_SHORT4N:
GL_EXTCALL(glVertexAttrib4NsvARB(i, (GLshort *) ptr));
GL_EXTCALL(glVertexAttrib4NsvARB(i, (const GLshort *)ptr));
break;
case WINED3DDECLTYPE_USHORT4N:
GL_EXTCALL(glVertexAttrib4NusvARB(i, (GLushort *) ptr));
GL_EXTCALL(glVertexAttrib4NusvARB(i, (const GLushort *)ptr));
break;
case WINED3DDECLTYPE_UDEC3:
FIXME("Unsure about WINED3DDECLTYPE_UDEC3\n");
/*glVertexAttrib3usvARB(i, (GLushort *) ptr); Does not exist */
/*glVertexAttrib3usvARB(i, (const GLushort *)ptr); Does not exist */
break;
case WINED3DDECLTYPE_DEC3N:
FIXME("Unsure about WINED3DDECLTYPE_DEC3N\n");
/*glVertexAttrib3NusvARB(i, (GLushort *) ptr); Does not exist */
/*glVertexAttrib3NusvARB(i, (const GLushort *)ptr); Does not exist */
break;
case WINED3DDECLTYPE_FLOAT16_2:
@@ -4088,8 +4096,9 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, WineDi
}
/* Used from 2 different functions, and too big to justify making it inlined */
static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVertexStridedData *sd) {
UINT *offset = stateblock->streamOffset;
static void loadVertexData(IWineD3DStateBlockImpl *stateblock, const WineDirect3DVertexStridedData *sd)
{
const UINT *offset = stateblock->streamOffset;
GLint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? -1 : 0;
TRACE("Using fast vertex array code\n");
@@ -4130,10 +4139,11 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
checkGLcall("glWeightPointerARB");
if((sd->u.s.blendMatrixIndices.lpData) || (sd->u.s.blendMatrixIndices.VBO)){
static BOOL showfixme = TRUE;
if(showfixme){
static BOOL warned;
if (!warned)
{
FIXME("blendMatrixIndices support\n");
showfixme = FALSE;
warned = TRUE;
}
}
} else {
@@ -4271,9 +4281,9 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
WINED3D_ATR_GLTYPE(sd->u.s.specular.dwType),
sd->u.s.specular.dwStride,
sd->u.s.specular.lpData + stateblock->loadBaseVertexIndex * sd->u.s.specular.dwStride + offset[sd->u.s.specular.streamNo]);
vcheckGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
checkGLcall("glSecondaryColorPointerEXT(4, GL_UNSIGNED_BYTE, ...)");
glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT);
vcheckGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
checkGLcall("glEnableClientState(GL_SECONDARY_COLOR_ARRAY_EXT)");
} else {
/* Missing specular color is not critical, no warnings */
@@ -4295,9 +4305,8 @@ static void loadVertexData(IWineD3DStateBlockImpl *stateblock, WineDirect3DVerte
loadTexCoords(stateblock, sd, &curVBO);
}
static inline void drawPrimitiveTraceDataLocations(
WineDirect3DVertexStridedData *dataLocations) {
static inline void drawPrimitiveTraceDataLocations(const WineDirect3DVertexStridedData *dataLocations)
{
/* Dump out what parts we have supplied */
TRACE("Strided Data:\n");
TRACE_STRIDED((dataLocations), position);
@@ -4332,6 +4341,8 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
BOOL fixup = FALSE;
WineDirect3DVertexStridedData *dataLocations = &device->strided_streams;
BOOL useVertexShaderFunction;
BOOL load_numbered = FALSE;
BOOL load_named = FALSE;
if (device->vs_selected_mode != SHADER_NONE && stateblock->vertexShader &&
((IWineD3DVertexShaderImpl *)stateblock->vertexShader)->baseShader.function != NULL) {
@@ -4365,41 +4376,51 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCo
useVertexShaderFunction = FALSE;
}
/* Unload the old arrays before loading the new ones to get old junk out */
if(context->numberedArraysLoaded) {
unloadNumberedArrays(stateblock);
context->numberedArraysLoaded = FALSE;
}
if(context->namedArraysLoaded) {
unloadVertexData(stateblock);
context->namedArraysLoaded = FALSE;
}
if(useVertexShaderFunction) {
if(((IWineD3DVertexDeclarationImpl *) stateblock->vertexDecl)->half_float_conv_needed && !fixup) {
TRACE("Using drawStridedSlow with vertex shaders for FLOAT16 conversion\n");
device->useDrawStridedSlow = TRUE;
context->numberedArraysLoaded = FALSE;
} else {
TRACE("Loading numbered arrays\n");
loadNumberedArrays(stateblock, dataLocations);
load_numbered = TRUE;
device->useDrawStridedSlow = FALSE;
context->numberedArraysLoaded = TRUE;
}
} else if (fixup ||
(dataLocations->u.s.pSize.lpData == NULL &&
dataLocations->u.s.diffuse.lpData == NULL &&
dataLocations->u.s.specular.lpData == NULL)) {
/* Load the vertex data using named arrays */
TRACE("Loading vertex data\n");
loadVertexData(stateblock, dataLocations);
load_named = TRUE;
device->useDrawStridedSlow = FALSE;
context->namedArraysLoaded = TRUE;
} else {
TRACE("Not loading vertex data\n");
device->useDrawStridedSlow = TRUE;
}
if (context->numberedArraysLoaded && !load_numbered)
{
unloadNumberedArrays(stateblock, context);
context->numberedArraysLoaded = FALSE;
context->numbered_array_mask = 0;
}
else if (context->namedArraysLoaded)
{
unloadVertexData(stateblock);
context->namedArraysLoaded = FALSE;
}
if (load_numbered)
{
TRACE("Loading numbered arrays\n");
loadNumberedArrays(stateblock, dataLocations, context);
context->numberedArraysLoaded = TRUE;
}
else if (load_named)
{
TRACE("Loading vertex data\n");
loadVertexData(stateblock, dataLocations);
context->namedArraysLoaded = TRUE;
}
/* Generate some fixme's if unsupported functionality is being used */
#define BUFFER_OR_DATA(_attribute) dataLocations->u.s._attribute.lpData
/* TODO: Either support missing functionality in fixupVertices or by creating a shader to replace the pipeline. */
@@ -4511,11 +4532,6 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W
state_normalize(STATE_RENDER(WINED3DRS_NORMALIZENORMALS), stateblock, context);
}
} else {
/* We compile the shader here because we need the vertex declaration
* in order to determine if we need to do any swizzling for D3DCOLOR
* registers. If the shader is already compiled this call will do nothing. */
IWineD3DVertexShader_CompileShader(stateblock->vertexShader);
if(!context->last_was_vshader) {
int i;
static BOOL warned = FALSE;
@@ -4610,7 +4626,7 @@ static void viewport_vertexpart(DWORD state, IWineD3DStateBlockImpl *stateblock,
static void light(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
UINT Index = state - STATE_ACTIVELIGHT(0);
PLIGHTINFOEL *lightInfo = stateblock->activeLights[Index];
const PLIGHTINFOEL *lightInfo = stateblock->activeLights[Index];
if(!lightInfo) {
glDisable(GL_LIGHT0 + Index);
@@ -5445,7 +5461,8 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
#define GLINFO_LOCATION (*gl_info)
static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }
static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps)
{
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED |
WINED3DTEXOPCAPS_ADDSIGNED2X |
@@ -5483,8 +5500,22 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_in
static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
static void ffp_fragment_free(IWineD3DDevice *iface) {}
static BOOL ffp_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking shader format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
static BOOL ffp_color_fixup_supported(struct color_fixup_desc fixup)
{
if (TRACE_ON(d3d))
{
TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup);
}
/* We only support identity conversions. */
if (is_identity_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
}
@@ -5493,12 +5524,13 @@ const struct fragment_pipeline ffp_fragment_pipeline = {
ffp_fragment_get_caps,
ffp_fragment_alloc,
ffp_fragment_free,
ffp_conv_supported,
ffp_color_fixup_supported,
ffp_fragmentstate_template,
FALSE /* we cannot disable projected textures. The vertex pipe has to do it */
};
static int num_handlers(APPLYSTATEFUNC *funcs) {
static unsigned int num_handlers(const APPLYSTATEFUNC *funcs)
{
unsigned int i;
for(i = 0; funcs[i]; i++);
return i;
@@ -5515,12 +5547,10 @@ static void multistate_apply_3(DWORD state, IWineD3DStateBlockImpl *stateblock,
stateblock->wineD3DDevice->multistate_funcs[state][2](state, stateblock, context);
}
void compile_state_table(struct StateEntry *StateTable,
APPLYSTATEFUNC **dev_multistate_funcs,
WineD3D_GL_Info *gl_info,
const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment,
const struct StateEntryTemplate *misc) {
void compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
const WineD3D_GL_Info *gl_info, const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc)
{
unsigned int i, type, handlers;
APPLYSTATEFUNC multistate_funcs[STATE_HIGHEST + 1][3];
const struct StateEntryTemplate *cur;
+11 -14
View File
@@ -63,11 +63,8 @@ HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object) {
}
/** Copy all members of one stateblock to another */
void stateblock_savedstates_copy(
IWineD3DStateBlock* iface,
SAVEDSTATES* dest,
SAVEDSTATES* source) {
static void stateblock_savedstates_copy(IWineD3DStateBlock* iface, SAVEDSTATES *dest, const SAVEDSTATES *source)
{
IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface;
unsigned bsize = sizeof(BOOL);
@@ -90,10 +87,10 @@ void stateblock_savedstates_copy(
memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memcpy(dest->samplerState, source->samplerState, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
memcpy(dest->clipplane, source->clipplane, bsize * MAX_CLIPPLANES);
memcpy(dest->pixelShaderConstantsB, source->pixelShaderConstantsB, bsize * MAX_CONST_B);
memcpy(dest->pixelShaderConstantsI, source->pixelShaderConstantsI, bsize * MAX_CONST_I);
memcpy(dest->vertexShaderConstantsB, source->vertexShaderConstantsB, bsize * MAX_CONST_B);
memcpy(dest->vertexShaderConstantsI, source->vertexShaderConstantsI, bsize * MAX_CONST_I);
dest->pixelShaderConstantsB = source->pixelShaderConstantsB;
dest->pixelShaderConstantsI = source->pixelShaderConstantsI;
dest->vertexShaderConstantsB = source->vertexShaderConstantsB;
dest->vertexShaderConstantsI = source->vertexShaderConstantsI;
/* Dynamically sized arrays */
memcpy(dest->pixelShaderConstantsF, source->pixelShaderConstantsF, bsize * GL_LIMITS(pshader_constantsF));
@@ -128,10 +125,10 @@ void stateblock_savedstates_set(
memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
memset(states->samplerState, value, bsize * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
memset(states->clipplane, value, bsize * MAX_CLIPPLANES);
memset(states->pixelShaderConstantsB, value, bsize * MAX_CONST_B);
memset(states->pixelShaderConstantsI, value, bsize * MAX_CONST_I);
memset(states->vertexShaderConstantsB, value, bsize * MAX_CONST_B);
memset(states->vertexShaderConstantsI, value, bsize * MAX_CONST_I);
states->pixelShaderConstantsB = value ? 0xffff : 0;
states->pixelShaderConstantsI = value ? 0xffff : 0;
states->vertexShaderConstantsB = value ? 0xffff : 0;
states->vertexShaderConstantsI = value ? 0xffff : 0;
/* Dynamically sized arrays */
memset(states->pixelShaderConstantsF, value, bsize * GL_LIMITS(pshader_constantsF));
@@ -710,7 +707,7 @@ static inline void apply_lights(IWineD3DDevice *pDevice, IWineD3DStateBlockImpl
struct list *e;
LIST_FOR_EACH(e, &This->lightMap[i]) {
PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
const PLIGHTINFOEL *light = LIST_ENTRY(e, PLIGHTINFOEL, entry);
if(light->changed) {
IWineD3DDevice_SetLight(pDevice, light->OriginalIndex, &light->OriginalParms);
+150 -224
View File
@@ -31,12 +31,11 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
WINE_DECLARE_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *surf);
static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4], BOOL colorkey);
static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES convert);
static inline void clear_unused_channels(IWineD3DSurfaceImpl *This);
static void surface_remove_pbo(IWineD3DSurfaceImpl *This);
void surface_force_reload(IWineD3DSurface *iface)
@@ -210,8 +209,9 @@ static void surface_download_data(IWineD3DSurfaceImpl *This) {
LEAVE_GL();
if (This->Flags & SFLAG_NONPOW2) {
LPBYTE src_data, dst_data;
int y;
const BYTE *src_data;
BYTE *dst_data;
UINT y;
/*
* Some games (e.g. warhammer 40k) don't work properly with the odd pitches, preventing
* the surface pitch from being used to box non-power2 textures. Instead we have to use a hack to
@@ -346,7 +346,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi
* activating the right context and binding the correct texture. */
static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) {
BOOL enable_client_storage = FALSE;
BYTE *mem = NULL;
const BYTE *mem = NULL;
if(This->heightscale != 1.0 && This->heightscale != 0.0) height *= This->heightscale;
@@ -443,7 +443,7 @@ void surface_set_compatible_renderbuffer(IWineD3DSurface *iface, unsigned int wi
}
if (!renderbuffer) {
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
GL_EXTCALL(glGenRenderbuffersEXT(1, &renderbuffer));
@@ -480,7 +480,8 @@ GLenum surface_get_gl_buffer(IWineD3DSurface *iface, IWineD3DSwapChain *swapchai
return GL_BACK;
}
ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
static ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -527,7 +528,7 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
HeapFree(GetProcessHeap(), 0, This->palette9);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
if(This->overlay_dest) {
list_remove(&This->overlay_entry);
@@ -544,7 +545,8 @@ ULONG WINAPI IWineD3DSurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DResource parts follow
**************************************************** */
void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface) {
static void WINAPI IWineD3DSurfaceImpl_PreLoad(IWineD3DSurface *iface)
{
/* TODO: check for locks */
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL;
@@ -674,22 +676,13 @@ static void WINAPI IWineD3DSurfaceImpl_UnLoad(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DSurface parts follow
****************************************************** */
void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
static void WINAPI IWineD3DSurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p) : returning %p\n", This, &This->glDescription);
*glDescription = &This->glDescription;
}
/* TODO: think about moving this down to resource? */
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* This should only be called for sysmem textures, it may be a good idea to extend this to all pools at some point in the future */
if (This->resource.pool != WINED3DPOOL_SYSTEMMEM) {
FIXME(" (%p)Attempting to get system memory for a non-system memory texture\n", iface);
}
return (CONST void*)(This->resource.allocatedMemory);
}
/* Read the framebuffer back into the surface */
static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, void *dest, UINT pitch) {
IWineD3DSwapChainImpl *swapchain;
@@ -803,7 +796,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
local_rect.right - local_rect.left,
local_rect.bottom - local_rect.top,
fmt, type, mem);
vcheckGLcall("glReadPixels");
checkGLcall("glReadPixels");
if(This->Flags & SFLAG_PBO) {
GL_EXTCALL(glBindBufferARB(GL_PIXEL_PACK_BUFFER_ARB, 0));
@@ -864,7 +857,7 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
* In case of P8 render targets, the index is stored in the alpha component so no conversion is needed.
*/
if((This->resource.format == WINED3DFMT_P8) && !primary_render_target_is_p8(myDevice)) {
PALETTEENTRY *pal = NULL;
const PALETTEENTRY *pal = NULL;
DWORD width = pitch / 3;
int x, y, c;
@@ -879,9 +872,9 @@ static void read_from_framebuffer(IWineD3DSurfaceImpl *This, CONST RECT *rect, v
for(y = local_rect.top; y < local_rect.bottom; y++) {
for(x = local_rect.left; x < local_rect.right; x++) {
/* start lines pixels */
BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3);
BYTE *green = blue + 1;
BYTE *red = green + 1;
const BYTE *blue = mem + y * pitch + x * (sizeof(BYTE) * 3);
const BYTE *green = blue + 1;
const BYTE *red = green + 1;
for(c = 0; c < 256; c++) {
if(*red == pal[c].peRed &&
@@ -951,8 +944,6 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
This->pow2Height, format, type);
}
clear_unused_channels(This);
ENTER_GL();
/* If !SrcIsUpsideDown we should flip the surface.
* This can be done using glCopyTexSubImage2D but this
@@ -968,7 +959,7 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This)
checkGLcall("glCopyTexSubImage2D");
glReadBuffer(prevRead);
vcheckGLcall("glReadBuffer");
checkGLcall("glReadBuffer");
LEAVE_GL();
TRACE("Updated target %d\n", This->glDescription.target);
@@ -1216,18 +1207,18 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
}
glGetIntegerv(GL_PACK_SWAP_BYTES, &prev_store);
vcheckGLcall("glIntegerv");
checkGLcall("glIntegerv");
glGetIntegerv(GL_CURRENT_RASTER_POSITION, &prev_rasterpos[0]);
vcheckGLcall("glIntegerv");
checkGLcall("glIntegerv");
glPixelZoom(1.0, -1.0);
vcheckGLcall("glPixelZoom");
checkGLcall("glPixelZoom");
/* If not fullscreen, we need to skip a number of bytes to find the next row of data */
glGetIntegerv(GL_UNPACK_ROW_LENGTH, &skipBytes);
glPixelStorei(GL_UNPACK_ROW_LENGTH, This->currentDesc.Width);
glRasterPos3i(This->lockedRect.left, This->lockedRect.top, 1);
vcheckGLcall("glRasterPos2f");
checkGLcall("glRasterPos2f");
/* Some drivers(radeon dri, others?) don't like exceptions during
* glDrawPixels. If the surface is a DIB section, it might be in GDIMode
@@ -1270,14 +1261,14 @@ static void flush_to_framebuffer_drawpixels(IWineD3DSurfaceImpl *This, GLenum fm
}
glPixelZoom(1.0,1.0);
vcheckGLcall("glPixelZoom");
checkGLcall("glPixelZoom");
glRasterPos3iv(&prev_rasterpos[0]);
vcheckGLcall("glRasterPos3iv");
checkGLcall("glRasterPos3iv");
/* Reset to previous pack row length */
glPixelStorei(GL_UNPACK_ROW_LENGTH, skipBytes);
vcheckGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
checkGLcall("glPixelStorei GL_UNPACK_ROW_LENGTH");
if(!swapchain) {
glDrawBuffer(myDevice->offscreenBuffer);
@@ -1405,7 +1396,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_UnlockRect(IWineD3DSurface *iface) {
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
static HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
WINED3DLOCKED_RECT lock;
HRESULT hr;
@@ -1470,7 +1462,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
/* GetDC on palettized formats is unsupported in D3D9, and the method is missing in
D3D8, so this should only be used for DX <=7 surfaces (with non-device palettes) */
unsigned int n;
PALETTEENTRY *pal = NULL;
const PALETTEENTRY *pal = NULL;
if(This->palette) {
pal = This->palette->palents;
@@ -1501,7 +1493,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
static HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,hDC);
@@ -1533,7 +1526,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode) {
BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT);
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
@@ -1707,38 +1700,6 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
*target_bpp = 2;
break;
case WINED3DFMT_R32F:
/* Can be loaded in theory with fmt=GL_RED, type=GL_FLOAT, but this fails. The reason
* is that D3D expects the undefined green, blue and alpha channels to return 1.0
* when sampling, but OpenGL sets green and blue to 0.0 instead. Thus we have to inject
* 1.0 instead.
*
* The alpha channel defaults to 1.0 in opengl, so nothing has to be done about it.
*/
*convert = CONVERT_R32F;
*format = GL_RGB;
*internal = GL_RGB32F_ARB;
*type = GL_FLOAT;
*target_bpp = 12;
break;
case WINED3DFMT_R16F:
/* Similar to R32F */
*convert = CONVERT_R16F;
*format = GL_RGB;
*internal = GL_RGB16F_ARB;
*type = GL_HALF_FLOAT_ARB;
*target_bpp = 6;
break;
case WINED3DFMT_G16R16:
*convert = CONVERT_G16R16;
*format = GL_RGB;
*internal = GL_RGB16_EXT;
*type = GL_UNSIGNED_SHORT;
*target_bpp = 6;
break;
default:
break;
}
@@ -1746,8 +1707,11 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_
return WINED3D_OK;
}
HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This) {
BYTE *source, *dest;
static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width,
UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This)
{
const BYTE *source;
BYTE *dest;
TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This);
switch (convert) {
@@ -1798,13 +1762,13 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
on the same surface and disables color keying in such a case
*/
unsigned int x, y;
WORD *Source;
const WORD *Source;
WORD *Dest;
TRACE("Color keyed 565\n");
for (y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Source = (const WORD *)(src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD color = *Source++;
@@ -1823,11 +1787,11 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
{
/* Converting X1R5G5B5 format to R5G5B5A1 to emulate color-keying. */
unsigned int x, y;
WORD *Source;
const WORD *Source;
WORD *Dest;
TRACE("Color keyed 5551\n");
for (y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Source = (const WORD *)(src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD color = *Source++;
@@ -1845,6 +1809,29 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
}
break;
case CONVERT_CK_RGB24:
{
/* Converting R8G8B8 format to R8G8B8A8 with color-keying. */
unsigned int x, y;
for (y = 0; y < height; y++)
{
source = src + pitch * y;
dest = dst + outpitch * y;
for (x = 0; x < width; x++) {
DWORD color = ((DWORD)source[0] << 16) + ((DWORD)source[1] << 8) + (DWORD)source[2] ;
DWORD dstcolor = color << 8;
if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
(color > This->SrcBltCKey.dwColorSpaceHighValue)) {
dstcolor |= 0xff;
}
*(DWORD*)dest = dstcolor;
source += 3;
dest += 4;
}
}
}
break;
case CONVERT_RGB32_888:
{
/* Converting X8R8G8B8 format to R8G8B8A8 with color-keying. */
@@ -1854,7 +1841,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
source = src + pitch * y;
dest = dst + outpitch * y;
for (x = 0; x < width; x++) {
DWORD color = 0xffffff & *(DWORD*)source;
DWORD color = 0xffffff & *(const DWORD*)source;
DWORD dstcolor = color << 8;
if ((color < This->SrcBltCKey.dwColorSpaceLowValue) ||
(color > This->SrcBltCKey.dwColorSpaceHighValue)) {
@@ -1871,10 +1858,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_V8U8:
{
unsigned int x, y;
short *Source;
const short *Source;
unsigned char *Dest;
for(y = 0; y < height; y++) {
Source = (short *) (src + y * pitch);
Source = (const short *)(src + y * pitch);
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) {
long color = (*Source++);
@@ -1890,10 +1877,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_V16U16:
{
unsigned int x, y;
DWORD *Source;
const DWORD *Source;
unsigned short *Dest;
for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch);
Source = (const DWORD *)(src + y * pitch);
Dest = (unsigned short *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
DWORD color = (*Source++);
@@ -1909,10 +1896,10 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_Q8W8V8U8:
{
unsigned int x, y;
DWORD *Source;
const DWORD *Source;
unsigned char *Dest;
for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch);
Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) {
long color = (*Source++);
@@ -1929,7 +1916,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_L6V5U5:
{
unsigned int x, y;
WORD *Source;
const WORD *Source;
unsigned char *Dest;
if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1938,7 +1925,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* loaded
*/
for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Source = (const WORD *)(src + y * pitch);
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) {
short color = (*Source++);
@@ -1963,7 +1950,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
} else {
for(y = 0; y < height; y++) {
unsigned short *Dest_s = (unsigned short *) (dst + y * outpitch);
Source = (WORD *) (src + y * pitch);
Source = (const WORD *)(src + y * pitch);
for (x = 0; x < width; x++ ) {
short color = (*Source++);
unsigned char l = ((color >> 10) & 0xfc);
@@ -1983,7 +1970,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_X8L8V8U8:
{
unsigned int x, y;
DWORD *Source;
const DWORD *Source;
unsigned char *Dest;
if(GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -1991,7 +1978,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* without further modification after converting the surface.
*/
for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch);
Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) {
long color = (*Source++);
@@ -2008,7 +1995,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
* standard fixed function pipeline anyway).
*/
for(y = 0; y < height; y++) {
Source = (DWORD *) (src + y * pitch);
Source = (const DWORD *)(src + y * pitch);
Dest = dst + y * outpitch;
for (x = 0; x < width; x++ ) {
long color = (*Source++);
@@ -2025,7 +2012,7 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
case CONVERT_A4L4:
{
unsigned int x, y;
unsigned char *Source;
const unsigned char *Source;
unsigned char *Dest;
for(y = 0; y < height; y++) {
Source = src + y * pitch;
@@ -2040,66 +2027,6 @@ HRESULT d3dfmt_convert_surface(BYTE *src, BYTE *dst, UINT pitch, UINT width, UIN
break;
}
case CONVERT_R32F:
{
unsigned int x, y;
float *Source;
float *Dest;
for(y = 0; y < height; y++) {
Source = (float *) (src + y * pitch);
Dest = (float *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
float color = (*Source++);
Dest[0] = color;
Dest[1] = 1.0;
Dest[2] = 1.0;
Dest += 3;
}
}
break;
}
case CONVERT_R16F:
{
unsigned int x, y;
WORD *Source;
WORD *Dest;
WORD one = 0x3c00;
for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD color = (*Source++);
Dest[0] = color;
Dest[1] = one;
Dest[2] = one;
Dest += 3;
}
}
break;
}
case CONVERT_G16R16:
{
unsigned int x, y;
WORD *Source;
WORD *Dest;
for(y = 0; y < height; y++) {
Source = (WORD *) (src + y * pitch);
Dest = (WORD *) (dst + y * outpitch);
for (x = 0; x < width; x++ ) {
WORD green = (*Source++);
WORD red = (*Source++);
Dest[0] = green;
Dest[1] = red;
Dest[2] = 0xffff;
Dest += 3;
}
}
break;
}
default:
ERR("Unsupported conversation type %d\n", convert);
}
@@ -2111,7 +2038,7 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL index_in_alpha = FALSE;
int dxVersion = ( (IWineD3DImpl *) device->wineD3D)->dxVersion;
int i;
unsigned int i;
/* Old games like StarCraft, C&C, Red Alert and others use P8 render targets.
* Reading back the RGB output each lockrect (each frame as they lock the whole screen)
@@ -2165,15 +2092,6 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4]
}
}
const char *fragment_palette_conversion =
"!!ARBfp1.0\n"
"TEMP index;\n"
"PARAM constants = { 0.996, 0.00195, 0, 0 };\n" /* { 255/256, 0.5/255*255/256, 0, 0 } */
"TEX index, fragment.texcoord[0], texture[0], 2D;\n" /* The alpha-component contains the palette index */
"MAD index.a, index.a, constants.x, constants.y;\n" /* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
"TEX result.color, index.a, texture[1], 1D;\n" /* use the alpha-component as a index in the palette to get the final color */
"END";
/* This function is used in case of 8bit paletted textures to upload the palette.
It supports GL_EXT_paletted_texture and GL_ARB_fragment_program, support for other
extensions like ATI_fragment_shaders is possible.
@@ -2200,6 +2118,19 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve
/* Create the fragment program if we don't have it */
if(!device->paletteConversionShader)
{
const char *fragment_palette_conversion =
"!!ARBfp1.0\n"
"TEMP index;\n"
/* { 255/256, 0.5/255*255/256, 0, 0 } */
"PARAM constants = { 0.996, 0.00195, 0, 0 };\n"
/* The alpha-component contains the palette index */
"TEX index, fragment.texcoord[0], texture[0], 2D;\n"
/* Scale the index by 255/256 and add a bias of '0.5' in order to sample in the middle */
"MAD index.a, index.a, constants.x, constants.y;\n"
/* Use the alpha-component as an index in the palette to get the final color */
"TEX result.color, index.a, texture[1], 1D;\n"
"END";
glEnable(GL_FRAGMENT_PROGRAM_ARB);
GL_EXTCALL(glGenProgramsARB(1, &device->paletteConversionShader));
GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, device->paletteConversionShader));
@@ -2247,41 +2178,6 @@ BOOL palette9_changed(IWineD3DSurfaceImpl *This) {
return TRUE;
}
static inline void clear_unused_channels(IWineD3DSurfaceImpl *This) {
GLboolean oldwrite[4];
/* Some formats have only some color channels, and the others are 1.0.
* since our rendering renders to all channels, and those pixel formats
* are emulated by using a full texture with the other channels set to 1.0
* manually, clear the unused channels.
*
* This could be done with hacking colorwriteenable to mask the colors,
* but before drawing the buffer would have to be cleared too, so there's
* no gain in that
*/
switch(This->resource.format) {
case WINED3DFMT_R16F:
case WINED3DFMT_R32F:
TRACE("R16F or R32F format, clearing green, blue and alpha to 1.0\n");
/* Do not activate a context, the correct drawable is active already
* though just the read buffer is set, make sure to have the correct draw
* buffer too
*/
glDrawBuffer(This->resource.wineD3DDevice->offscreenBuffer);
glDisable(GL_SCISSOR_TEST);
glGetBooleanv(GL_COLOR_WRITEMASK, oldwrite);
glColorMask(GL_FALSE, GL_TRUE, GL_TRUE, GL_TRUE);
glClearColor(0.0, 1.0, 1.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glColorMask(oldwrite[0], oldwrite[1], oldwrite[2], oldwrite[3]);
if(!This->resource.wineD3DDevice->render_offscreen) glDrawBuffer(GL_BACK);
checkGLcall("Unused channel clear\n");
break;
default: break;
}
}
static HRESULT WINAPI IWineD3DSurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
@@ -2407,14 +2303,14 @@ static void WINAPI IWineD3DSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
#include <errno.h>
#include <stdio.h>
HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename) {
static HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const char* filename)
{
FILE* f = NULL;
UINT i, y;
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
char *allocatedMemory;
char *textureRow;
const char *textureRow;
IWineD3DSwapChain *swapChain = NULL;
int width, height;
int width, height, i, y;
GLuint tmpTexture = 0;
DWORD color;
/*FIXME:
@@ -2458,9 +2354,9 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
NULL);
glGetIntegerv(GL_READ_BUFFER, &prevRead);
vcheckGLcall("glGetIntegerv");
checkGLcall("glGetIntegerv");
glReadBuffer(swapChain ? GL_BACK : This->resource.wineD3DDevice->offscreenBuffer);
vcheckGLcall("glReadBuffer");
checkGLcall("glReadBuffer");
glCopyTexImage2D(GL_TEXTURE_2D,
0,
GL_RGBA,
@@ -2528,7 +2424,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
textureRow = allocatedMemory;
for (y = 0 ; y < height; y++) {
for (i = 0; i < width; i++) {
color = *((DWORD*)textureRow);
color = *((const DWORD*)textureRow);
fputc((color >> 16) & 0xFF, f); /* B */
fputc((color >> 8) & 0xFF, f); /* G */
fputc((color >> 0) & 0xFF, f); /* R */
@@ -2553,7 +2449,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SaveSnapshot(IWineD3DSurface *iface, const ch
/**
* Slightly inefficient way to handle multiple dirty rects but it works :)
*/
HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
static HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DBaseTexture *baseTexture = NULL;
@@ -2583,10 +2480,10 @@ HRESULT WINAPI IWineD3DSurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RE
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
static HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
HRESULT hr;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : Calling base function first\n", This);
@@ -2604,7 +2501,7 @@ HRESULT WINAPI IWineD3DSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORM
return hr;
}
HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
static HRESULT WINAPI IWineD3DSurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
if(This->Flags & (SFLAG_LOCKED | SFLAG_DCINUSE)) {
@@ -2797,7 +2694,10 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Flip(IWineD3DSurface *iface, IWineD3DS
/* Does a direct frame buffer -> texture copy. Stretching is done
* with single pixel copy calls
*/
static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) {
static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
{
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
float xrel, yrel;
UINT row;
@@ -2875,13 +2775,16 @@ static inline void fb_copy_to_texture_direct(IWineD3DSurfaceImpl *This, IWineD3D
}
}
}
vcheckGLcall("glCopyTexSubImage2D");
checkGLcall("glCopyTexSubImage2D");
LEAVE_GL();
}
/* Uses the hardware to stretch and flip the image */
static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface, IWineD3DSwapChainImpl *swapchain, WINED3DRECT *srect, WINED3DRECT *drect, BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter) {
static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWineD3DSurface *SrcSurface,
IWineD3DSwapChainImpl *swapchain, const WINED3DRECT *srect, const WINED3DRECT *drect,
BOOL upsidedown, WINED3DTEXTUREFILTERTYPE Filter)
{
GLuint src, backup = 0;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -2957,7 +2860,7 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(texture_target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]);
minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
if(!swapchain || (IWineD3DSurface *) Src == swapchain->backBuffer[0]) {
@@ -3117,7 +3020,10 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
}
/* Not called from the VTable */
static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, const RECT *DestRect,
IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx,
WINED3DTEXTUREFILTERTYPE Filter)
{
WINED3DRECT rect;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
IWineD3DSwapChainImpl *srcSwapchain = NULL, *dstSwapchain = NULL;
@@ -3494,7 +3400,7 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
magLookup[Filter - WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_MIN_FILTER,
minMipLookup[Filter][WINED3DTEXF_NONE]);
minMipLookup[Filter].mip[WINED3DTEXF_NONE]);
checkGLcall("glTexParameteri");
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(Src->glDescription.target, GL_TEXTURE_WRAP_T, GL_CLAMP);
@@ -3648,7 +3554,8 @@ static HRESULT IWineD3DSurfaceImpl_BltOverride(IWineD3DSurfaceImpl *This, RECT *
return WINED3DERR_INVALIDCALL;
}
static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx)
static HRESULT IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, const RECT *DestRect,
IWineD3DSurface *SrcSurface, const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx)
{
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
float depth;
@@ -3675,7 +3582,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
return IWineD3DDevice_Clear((IWineD3DDevice *) myDevice,
DestRect == NULL ? 0 : 1,
(WINED3DRECT *) DestRect,
(const WINED3DRECT *)DestRect,
WINED3DCLEAR_ZBUFFER,
0x00000000,
depth,
@@ -3686,7 +3593,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_BltZ(IWineD3DSurfaceImpl *This, RECT *
return WINED3DERR_INVALIDCALL;
}
static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3725,7 +3633,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *Dest
return IWineD3DBaseSurfaceImpl_Blt(iface, DestRect, SrcSurface, SrcRect, Flags, DDBltFx, Filter);
}
HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans) {
static HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *srcImpl = (IWineD3DSurfaceImpl *) Source;
IWineD3DDeviceImpl *myDevice = This->resource.wineD3DDevice;
@@ -3785,7 +3695,8 @@ HRESULT WINAPI IWineD3DSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, D
return IWineD3DBaseSurfaceImpl_BltFast(iface, dstx, dsty, Source, rsrc, trans);
}
HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
static HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette;
@@ -3849,7 +3760,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) {
/** Check against the maximum texture sizes supported by the video card **/
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
unsigned int pow2Width, pow2Height;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(This->resource.format, &GLINFO_LOCATION, &glDesc);
/* Setup some glformat defaults */
@@ -4674,7 +4585,8 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container) {
static HRESULT WINAPI IWineD3DSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSwapChain *swapchain = NULL;
@@ -4772,7 +4684,7 @@ const IWineD3DSurfaceVtbl IWineD3DSurface_Vtbl =
IWineD3DSurfaceImpl_SaveSnapshot,
IWineD3DSurfaceImpl_SetContainer,
IWineD3DSurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_GetData,
IWineD3DSurfaceImpl_SetFormat,
IWineD3DSurfaceImpl_PrivateSetup,
IWineD3DSurfaceImpl_ModifyLocation,
@@ -4806,8 +4718,22 @@ static void ffp_blit_unset(IWineD3DDevice *iface) {
}
}
static BOOL ffp_blit_conv_supported(WINED3DFORMAT fmt) {
TRACE("Checking blit format support for format %s: [FAILED]\n", debug_d3dformat(fmt));
static BOOL ffp_blit_color_fixup_supported(struct color_fixup_desc fixup)
{
if (TRACE_ON(d3d_surface) && TRACE_ON(d3d))
{
TRACE("Checking support for fixup:\n");
dump_color_fixup_desc(fixup);
}
/* We only support identity conversions. */
if (is_identity_fixup(fixup))
{
TRACE("[OK]\n");
return TRUE;
}
TRACE("[FAILED]\n");
return FALSE;
}
@@ -4816,5 +4742,5 @@ const struct blit_shader ffp_blit = {
ffp_blit_free,
ffp_blit_set,
ffp_blit_unset,
ffp_blit_conv_supported
ffp_blit_color_fixup_supported
};
+67 -50
View File
@@ -119,37 +119,37 @@ ULONG WINAPI IWineD3DBaseSurfaceImpl_AddRef(IWineD3DSurface *iface) {
IWineD3DSurface IWineD3DResource parts follow
**************************************************** */
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetDevice(IWineD3DSurface *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPrivateData(IWineD3DSurface *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPrivateData(IWineD3DSurface *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_FreePrivateData(IWineD3DSurface *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
DWORD WINAPI IWineD3DBaseSurfaceImpl_SetPriority(IWineD3DSurface *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPriority(IWineD3DSurface *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
WINED3DRESOURCETYPE WINAPI IWineD3DBaseSurfaceImpl_GetType(IWineD3DSurface *iface) {
TRACE("(%p) : calling resourceimpl_GetType\n", iface);
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetParent(IWineD3DSurface *iface, IUnknown **pParent) {
TRACE("(%p) : calling resourceimpl_GetParent\n", iface);
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
@@ -269,7 +269,8 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD
else return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey) {
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
TRACE("(%p)->(%08x,%p)\n", This, Flags, CKey);
@@ -418,7 +419,9 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *ifac
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX) {
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Dst = (IWineD3DSurfaceImpl *) DstSurface;
TRACE("(%p)->(%p, %p, %p, %08x, %p)\n", This, SrcRect, Dst, DstRect, Flags, FX);
@@ -682,14 +685,16 @@ HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface) {
return WINED3D_OK;
}
void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h) {
static void convert_r32f_r16f(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out,
unsigned int w, unsigned int h)
{
unsigned int x, y;
float *src_f;
const float *src_f;
unsigned short *dst_s;
TRACE("Converting %dx%d pixels, pitches %d %d\n", w, h, pitch_in, pitch_out);
for(y = 0; y < h; y++) {
src_f = (float *) (src + y * pitch_in);
src_f = (const float *)(src + y * pitch_in);
dst_s = (unsigned short *) (dst + y * pitch_out);
for(x = 0; x < w; x++) {
dst_s[x] = float_32_to_16(src_f + x);
@@ -699,14 +704,16 @@ void convert_r32f_r16f(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, un
struct d3dfmt_convertor_desc {
WINED3DFORMAT from, to;
void (*convert)(BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
void (*convert)(const BYTE *src, BYTE *dst, DWORD pitch_in, DWORD pitch_out, unsigned int w, unsigned int h);
};
struct d3dfmt_convertor_desc convertors[] = {
static const struct d3dfmt_convertor_desc convertors[] =
{
{WINED3DFMT_R32F, WINED3DFMT_R16F, convert_r32f_r16f},
};
static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to) {
static inline const struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, WINED3DFORMAT to)
{
unsigned int i;
for(i = 0; i < (sizeof(convertors) / sizeof(convertors[0])); i++) {
if(convertors[i].from == from && convertors[i].to == to) {
@@ -727,9 +734,9 @@ static inline struct d3dfmt_convertor_desc *find_convertor(WINED3DFORMAT from, W
* fmt: Requested destination format
*
*****************************************************************************/
IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) {
static IWineD3DSurfaceImpl *surface_convert_format(IWineD3DSurfaceImpl *source, WINED3DFORMAT to_fmt) {
IWineD3DSurface *ret = NULL;
struct d3dfmt_convertor_desc *conv;
const struct d3dfmt_convertor_desc *conv;
WINED3DLOCKED_RECT lock_src, lock_dst;
HRESULT hr;
@@ -862,14 +869,8 @@ static HRESULT
* SrcSurface: Source surface, can be NULL
* SrcRect: Source rectangle
*****************************************************************************/
HRESULT WINAPI
IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
RECT *DestRect,
IWineD3DSurface *SrcSurface,
RECT *SrcRect,
DWORD Flags,
WINEDDBLTFX *DDBltFx,
WINED3DTEXTUREFILTERTYPE Filter)
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) SrcSurface;
@@ -880,7 +881,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
int bpp, srcheight, srcwidth, dstheight, dstwidth, width;
int x, y;
const StaticPixelFormatDesc *sEntry, *dEntry;
LPBYTE dbuf, sbuf;
const BYTE *sbuf;
BYTE *dbuf;
TRACE("(%p)->(%p,%p,%p,%x,%p)\n", This, DestRect, Src, SrcRect, Flags, DDBltFx);
if (TRACE_ON(d3d_surface))
@@ -1171,7 +1173,7 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
/* Now the 'with source' blits */
if (Src)
{
LPBYTE sbase;
const BYTE *sbase;
int sx, xinc, sy, yinc;
if (!dstwidth || !dstheight) /* hmm... stupid program ? */
@@ -1250,7 +1252,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
else
{
#define STRETCH_ROW(type) { \
type *s = (type *) sbuf, *d = (type *) dbuf; \
const type *s = (const type *)sbuf; \
type *d = (type *)dbuf; \
for (x = sx = 0; x < dstwidth; x++, sx += xinc) \
d[x] = s[sx >> 16]; \
break; }
@@ -1262,7 +1265,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
case 4: STRETCH_ROW(DWORD)
case 3:
{
LPBYTE s,d = dbuf;
const BYTE *s;
BYTE *d = dbuf;
for (x = sx = 0; x < dstwidth; x++, sx+= xinc)
{
DWORD pixel;
@@ -1416,9 +1420,10 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
}
#define COPY_COLORKEY_FX(type) { \
type *s, *d = (type *) dbuf, *dx, tmp; \
const type *s; \
type *d = (type *)dbuf, *dx, tmp; \
for (y = sy = 0; y < dstheight; y++, sy += yinc) { \
s = (type*)(sbase + (sy >> 16) * slock.Pitch); \
s = (const type*)(sbase + (sy >> 16) * slock.Pitch); \
dx = d; \
for (x = sx = 0; x < dstwidth; x++, sx += xinc) { \
tmp = s[sx >> 16]; \
@@ -1438,7 +1443,8 @@ IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface,
case 4: COPY_COLORKEY_FX(DWORD)
case 3:
{
LPBYTE s,d = dbuf, dx;
const BYTE *s;
BYTE *d = dbuf, *dx;
for (y = sy = 0; y < dstheight; y++, sy += yinc)
{
sbuf = sbase + (sy >> 16) * slock.Pitch;
@@ -1504,13 +1510,8 @@ release:
* WINED3D_OK on success
*
*****************************************************************************/
HRESULT WINAPI
IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
DWORD dstx,
DWORD dsty,
IWineD3DSurface *Source,
RECT *rsrc,
DWORD trans)
HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
IWineD3DSurface *Source, const RECT *rsrc, DWORD trans)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
IWineD3DSurfaceImpl *Src = (IWineD3DSurfaceImpl *) Source;
@@ -1520,7 +1521,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
HRESULT ret = WINED3D_OK;
RECT rsrc2;
RECT lock_src, lock_dst, lock_union;
BYTE *sbuf, *dbuf;
const BYTE *sbuf;
BYTE *dbuf;
const StaticPixelFormatDesc *sEntry, *dEntry;
if (TRACE_ON(d3d_surface))
@@ -1548,11 +1550,11 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
if (!rsrc)
{
WARN("rsrc is NULL!\n");
rsrc2.left = 0;
rsrc2.top = 0;
rsrc2.right = Src->currentDesc.Width;
rsrc2.bottom = Src->currentDesc.Height;
rsrc = &rsrc2;
rsrc->left = 0;
rsrc->top = 0;
rsrc->right = Src->currentDesc.Width;
rsrc->bottom = Src->currentDesc.Height;
}
/* Check source rect for validity. Copied from normal Blt. Fixes Baldur's Gate.*/
@@ -1670,15 +1672,15 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
}
#define COPYBOX_COLORKEY(type) { \
type *d, *s, tmp; \
s = (type *) sbuf; \
d = (type *) dbuf; \
const type *s = (const type *)sbuf; \
type *d = (type *)dbuf; \
type tmp; \
for (y = 0; y < h; y++) { \
for (x = 0; x < w; x++) { \
tmp = s[x]; \
if (tmp < keylow || tmp > keyhigh) d[x] = tmp; \
} \
s = (type *)((BYTE *)s + slock.Pitch); \
s = (const type *)((const BYTE *)s + slock.Pitch); \
d = (type *)((BYTE *)d + dlock.Pitch); \
} \
break; \
@@ -1690,7 +1692,8 @@ IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface,
case 4: COPYBOX_COLORKEY(DWORD)
case 3:
{
BYTE *d, *s;
const BYTE *s;
BYTE *d;
DWORD tmp;
s = sbuf;
d = dbuf;
@@ -1826,3 +1829,17 @@ void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface) {
ERR("Should not be called on base texture\n");
return;
}
/* TODO: think about moving this down to resource? */
const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
/* This should only be called for sysmem textures, it may be a good idea
* to extend this to all pools at some point in the future */
if (This->resource.pool != WINED3DPOOL_SYSTEMMEM)
{
FIXME("(%p) Attempting to get system memory for a non-system memory texture\n", iface);
}
return This->resource.allocatedMemory;
}
+15 -15
View File
@@ -42,7 +42,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
* to destroy all the GL things.
*
*****************************************************************************/
ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
static ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
ULONG ref = InterlockedDecrement(&This->resource.ref);
TRACE("(%p) : Releasing from %d\n", This, ref + 1);
@@ -62,7 +62,7 @@ ULONG WINAPI IWineGDISurfaceImpl_Release(IWineD3DSurface *iface) {
HeapFree(GetProcessHeap(), 0, This->palette9);
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
if(This->overlay_dest) {
list_remove(&This->overlay_entry);
@@ -245,7 +245,7 @@ IWineGDISurfaceImpl_Flip(IWineD3DSurface *iface,
* D3DERR_INVALIDCALL
*
*****************************************************************************/
HRESULT WINAPI
static HRESULT WINAPI
IWineGDISurfaceImpl_LoadTexture(IWineD3DSurface *iface, BOOL srgb_mode)
{
ERR("Unsupported on X11 surfaces\n");
@@ -280,7 +280,7 @@ static int get_shift(DWORD color_mask) {
}
HRESULT WINAPI
static HRESULT WINAPI
IWineGDISurfaceImpl_SaveSnapshot(IWineD3DSurface *iface,
const char* filename)
{
@@ -288,7 +288,7 @@ const char* filename)
UINT y = 0, x = 0;
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
static char *output = NULL;
static int size = 0;
static UINT size = 0;
const StaticPixelFormatDesc *formatEntry = getFormatDescEntry(This->resource.format, NULL, NULL);
if (This->pow2Width > size) {
@@ -340,7 +340,7 @@ const char* filename)
alpha_shift = get_shift(formatEntry->alphaMask);
for (y = 0; y < This->pow2Height; y++) {
unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
const unsigned char *src = This->resource.allocatedMemory + (y * 1 * IWineD3DSurface_GetPitch(iface));
for (x = 0; x < This->pow2Width; x++) {
unsigned int color;
unsigned int comp;
@@ -366,7 +366,7 @@ const char* filename)
return WINED3D_OK;
}
HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
static HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
WINED3DLOCKED_RECT lock;
HRESULT hr;
@@ -405,7 +405,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
if(This->resource.format == WINED3DFMT_P8 ||
This->resource.format == WINED3DFMT_A8P8) {
unsigned int n;
PALETTEENTRY *pal = NULL;
const PALETTEENTRY *pal = NULL;
if(This->palette) {
pal = This->palette->palents;
@@ -436,7 +436,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_GetDC(IWineD3DSurface *iface, HDC *pHDC) {
return WINED3D_OK;
}
HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
static HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
TRACE("(%p)->(%p)\n",This,hDC);
@@ -457,7 +457,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_ReleaseDC(IWineD3DSurface *iface, HDC hDC) {
return WINED3D_OK;
}
HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
static HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
RGBQUAD col[256];
IWineD3DPaletteImpl *pal = This->palette;
@@ -507,7 +507,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_RealizePalette(IWineD3DSurface *iface) {
* The return values of called methods on failure
*
*****************************************************************************/
HRESULT WINAPI
static HRESULT WINAPI
IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
{
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
@@ -534,13 +534,13 @@ IWineGDISurfaceImpl_PrivateSetup(IWineD3DSurface *iface)
return WINED3D_OK;
}
void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
static void WINAPI IWineGDISurfaceImpl_GetGlDesc(IWineD3DSurface *iface, glDescriptor **glDescription) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface;
FIXME("(%p) : Should not be called on a GDI surface\n", This);
*glDescription = NULL;
}
HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
static HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RECT* pDirtyRect) {
/* GDI surface data can only be in one location, the system memory dib section. So they are
* always clean by definition.
*/
@@ -548,7 +548,7 @@ HRESULT WINAPI IWineGDISurfaceImpl_AddDirtyRect(IWineD3DSurface *iface, CONST RE
return WINED3D_OK;
}
HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
static HRESULT WINAPI IWineGDISurfaceImpl_SetMem(IWineD3DSurface *iface, void *Mem) {
IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface;
/* Render targets depend on their hdc, and we can't create an hdc on a user pointer */
@@ -679,7 +679,7 @@ const IWineD3DSurfaceVtbl IWineGDISurface_Vtbl =
IWineGDISurfaceImpl_SaveSnapshot,
IWineD3DBaseSurfaceImpl_SetContainer,
IWineGDISurfaceImpl_GetGlDesc,
IWineD3DSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_GetData,
IWineD3DBaseSurfaceImpl_SetFormat,
IWineGDISurfaceImpl_PrivateSetup,
IWineGDISurfaceImpl_ModifyLocation,
+3 -3
View File
@@ -39,7 +39,7 @@ WINE_DECLARE_DEBUG_CHANNEL(fps);
static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB_DESTROYSURFACEFN D3DCB_DestroyRenderTarget) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
WINED3DDISPLAYMODE mode;
int i;
unsigned int i;
TRACE("Destroying swapchain %p\n", iface);
@@ -54,7 +54,7 @@ static void WINAPI IWineD3DSwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
}
if(This->backBuffer) {
int i;
UINT i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) {
IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
if(D3DCB_DestroyRenderTarget(This->backBuffer[i]) > 0) {
@@ -138,7 +138,7 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO
IWineD3DSurface_BltFast(This->backBuffer[0], 0, 0, This->wineD3DDevice->logo_surface, NULL, WINEDDBLTFAST_SRCCOLORKEY);
}
if (pSourceRect || pDestRect) FIXME("Unhandled present options %p/%p\n", pSourceRect, pDestRect);
if (pSourceRect || pDestRect) FIXME("Unhandled present rects %s/%s\n", wine_dbgstr_rect(pSourceRect), wine_dbgstr_rect(pDestRect));
/* TODO: If only source rect or dest rect are supplied then clip the window to match */
TRACE("presetting HDC %p\n", This->context[0]->hdc);
@@ -122,13 +122,14 @@ HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetBackBuffer(IWineD3DSwapChain *iface,
HRESULT WINAPI IWineD3DBaseSwapChainImpl_GetRasterStatus(IWineD3DSwapChain *iface, WINED3DRASTER_STATUS *pRasterStatus) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
static BOOL showFixmes = TRUE;
static BOOL warned;
pRasterStatus->InVBlank = TRUE;
pRasterStatus->ScanLine = 0;
/* No openGL equivalent */
if(showFixmes) {
if (!warned)
{
FIXME("(%p) : stub (once)\n", This);
showFixmes = FALSE;
warned = TRUE;
}
return WINED3D_OK;
}
@@ -44,7 +44,7 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
}
if(This->backBuffer) {
int i;
UINT i;
for(i = 0; i < This->presentParms.BackBufferCount; i++) {
IWineD3DSurface_SetContainer(This->backBuffer[i], 0);
if(D3DCB_DestroyRenderback(This->backBuffer[i]) > 0) {
@@ -80,7 +80,8 @@ static void WINAPI IWineGDISwapChainImpl_Destroy(IWineD3DSwapChain *iface, D3DCB
* rc: Rectangle to copy
*
*****************************************************************************/
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc) {
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc)
{
IWineD3DSurfaceImpl *front = (IWineD3DSurfaceImpl *) This->frontBuffer;
if(front->resource.usage & WINED3DUSAGE_RENDERTARGET) {
@@ -238,18 +239,6 @@ static HRESULT WINAPI IWineGDISwapChainImpl_Present(IWineD3DSwapChain *iface, CO
return WINED3D_OK;
}
/* FIXME: This should not be needed, the base version is OK */
HRESULT WINAPI IWineGDIBaseSwapChainImpl_GetDisplayMode(IWineD3DSwapChain *iface, WINED3DDISPLAYMODE*pMode) {
IWineD3DSwapChainImpl *This = (IWineD3DSwapChainImpl *)iface;
IWineD3DDeviceImpl *device = This->wineD3DDevice;
pMode->Width = device->ddraw_width;
pMode->Height = device->ddraw_height;
pMode->Format = device->ddraw_format;
pMode->RefreshRate = 0;
return WINED3D_OK;
}
const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl =
{
/* IUnknown */
+20 -20
View File
@@ -69,27 +69,27 @@ static ULONG WINAPI IWineD3DTextureImpl_Release(IWineD3DTexture *iface) {
IWineD3DTexture IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DTextureImpl_GetDevice(IWineD3DTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DTextureImpl_SetPrivateData(IWineD3DTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DTextureImpl_GetPrivateData(IWineD3DTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DTextureImpl_FreePrivateData(IWineD3DTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DTextureImpl_SetPriority(IWineD3DTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DTextureImpl_GetPriority(IWineD3DTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DTextureImpl_PreLoad(IWineD3DTexture *iface) {
@@ -165,51 +165,51 @@ static void WINAPI IWineD3DTextureImpl_UnLoad(IWineD3DTexture *iface) {
surface_set_texture_name(This->surfaces[i], 0);
}
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
basetexture_unload((IWineD3DBaseTexture *)iface);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DTextureImpl_GetType(IWineD3DTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
static HRESULT WINAPI IWineD3DTextureImpl_GetParent(IWineD3DTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DTexture IWineD3DBaseTexture parts follow
****************************************************** */
static DWORD WINAPI IWineD3DTextureImpl_SetLOD(IWineD3DTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
}
static DWORD WINAPI IWineD3DTextureImpl_GetLOD(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
return basetexture_get_lod((IWineD3DBaseTexture *)iface);
}
static DWORD WINAPI IWineD3DTextureImpl_GetLevelCount(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DTextureImpl_SetAutoGenFilterType(IWineD3DTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
}
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DTextureImpl_GetAutoGenFilterType(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
}
static void WINAPI IWineD3DTextureImpl_GenerateMipSubLevels(IWineD3DTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DTextureImpl_SetDirty(IWineD3DTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
}
static BOOL WINAPI IWineD3DTextureImpl_GetDirty(IWineD3DTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
@@ -219,7 +219,7 @@ static HRESULT WINAPI IWineD3DTextureImpl_BindTexture(IWineD3DTexture *iface) {
TRACE("(%p) : relay to BaseTexture\n", This);
hr = IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
hr = basetexture_bind((IWineD3DBaseTexture *)iface);
if (set_gl_texture_desc && SUCCEEDED(hr)) {
UINT i;
for (i = 0; i < This->baseTexture.levels; ++i) {
@@ -270,7 +270,7 @@ static void WINAPI IWineD3DTextureImpl_ApplyStateChanges(IWineD3DTexture *iface,
const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
TRACE("(%p) : relay to BaseTexture\n", iface);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
/* *******************************************
@@ -291,7 +291,7 @@ static void WINAPI IWineD3DTextureImpl_Destroy(IWineD3DTexture *iface, D3DCB_DES
}
}
TRACE("(%p) : cleaning up base texture\n", This);
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *)iface);
basetexture_cleanup((IWineD3DBaseTexture *)iface);
/* free the object */
HeapFree(GetProcessHeap(), 0, This);
}
+125 -42
View File
@@ -318,7 +318,7 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glGammaInternal = gl_formats_template[src].glGammaInternal;
gl_info->gl_formats[dst].glFormat = gl_formats_template[src].glFormat;
gl_info->gl_formats[dst].glType = gl_formats_template[src].glType;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_UNKNOWN;
gl_info->gl_formats[dst].color_fixup = COLOR_FIXUP_IDENTITY;
gl_info->gl_formats[dst].Flags = gl_formats_template[src].Flags;
gl_info->gl_formats[dst].heightscale = 1.0;
@@ -363,29 +363,52 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
}
}
dst = getFmtIdx(WINED3DFMT_R16F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_R32F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_G16R16);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_G16R16F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_G32R32F);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_W);
/* V8U8 is supported natively by GL_ATI_envmap_bumpmap and GL_NV_texture_shader.
* V16U16 is only supported by GL_NV_texture_shader. The formats need fixup if
* their extensions are not available.
* their extensions are not available. GL_ATI_envmap_bumpmap is not used because
* the only driver that implements it(fglrx) has a buggy implementation.
*
* In theory, V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
* returns 0.0 when sampling from it, DirectX 1.0. This is disabled until we find
* an application that needs this because it causes performance problems due to
* shader recompiling in some games.
* V8U8 and V16U16 need a fixup of the undefined blue channel. OpenGL
* returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader
* conversion for this format.
*/
if(!GL_SUPPORT(NV_TEXTURE_SHADER2)) {
/* signed -> unsigned fixup */
if (!GL_SUPPORT(NV_TEXTURE_SHADER))
{
dst = getFmtIdx(WINED3DFMT_V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
dst = getFmtIdx(WINED3DFMT_V16U16);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
} else {
/* Blue = 1.0 fixup, disabled for now */
if(0) {
dst = getFmtIdx(WINED3DFMT_V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
dst = getFmtIdx(WINED3DFMT_V16U16);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_V8U8;
}
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
else
{
dst = getFmtIdx(WINED3DFMT_V8U8);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
dst = getFmtIdx(WINED3DFMT_V16U16);
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
if(!GL_SUPPORT(NV_TEXTURE_SHADER)) {
@@ -393,11 +416,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
* with each other
*/
dst = getFmtIdx(WINED3DFMT_L6V5U5);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_L6V5U5;
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE);
dst = getFmtIdx(WINED3DFMT_X8L8V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_X8L8V8U8;
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W);
dst = getFmtIdx(WINED3DFMT_Q8W8V8U8);
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_Q8W8V8U8;
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
1, CHANNEL_SOURCE_X, 1, CHANNEL_SOURCE_Y, 1, CHANNEL_SOURCE_Z, 1, CHANNEL_SOURCE_W);
} else {
/* If GL_NV_texture_shader is supported, WINED3DFMT_L6V5U5 and WINED3DFMT_X8L8V8U8
* are converted at surface loading time, but they do not need any modification in
@@ -410,12 +436,14 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
dst = getFmtIdx(WINED3DFMT_ATI2N);
gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_RED_GREEN_RGTC2_EXT;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N;
gl_info->gl_formats[dst].color_fixup = create_color_fixup_desc(
0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
} else if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) {
dst = getFmtIdx(WINED3DFMT_ATI2N);
gl_info->gl_formats[dst].glInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
gl_info->gl_formats[dst].glGammaInternal = GL_COMPRESSED_LUMINANCE_ALPHA_3DC_ATI;
gl_info->gl_formats[dst].conversion_group= WINED3DFMT_ATI2N;
gl_info->gl_formats[dst].color_fixup= create_color_fixup_desc(
0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE);
}
if(!GL_SUPPORT(APPLE_YCBCR_422)) {
@@ -424,19 +452,19 @@ BOOL initPixelFormats(WineD3D_GL_Info *gl_info)
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YUY2;
gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2);
dst = getFmtIdx(WINED3DFMT_UYVY);
gl_info->gl_formats[dst].glInternal = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glGammaInternal = GL_LUMINANCE_ALPHA; /* not srgb */
gl_info->gl_formats[dst].glFormat = GL_LUMINANCE_ALPHA;
gl_info->gl_formats[dst].glType = GL_UNSIGNED_BYTE;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_UYVY;
gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_UYVY);
}
dst = getFmtIdx(WINED3DFMT_YV12);
gl_info->gl_formats[dst].heightscale = 1.5;
gl_info->gl_formats[dst].conversion_group = WINED3DFMT_YV12;
gl_info->gl_formats[dst].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12);
return TRUE;
}
@@ -476,7 +504,8 @@ void init_type_lookup(WineD3D_GL_Info *gl_info) {
#define GLINFO_LOCATION This->adapter->gl_info
const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_Info *gl_info, const GlPixelFormatDesc **glDesc)
const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const WineD3D_GL_Info *gl_info,
const struct GlPixelFormatDesc **glDesc)
{
int idx = getFmtIdx(fmt);
@@ -491,7 +520,7 @@ const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, WineD3D_GL_In
* all gl caps check return "unsupported" than catching the lack of gl all over the code. ANSI C requires
* static variables to be initialized to 0.
*/
static const GlPixelFormatDesc dummyFmt;
static const struct GlPixelFormatDesc dummyFmt;
*glDesc = &dummyFmt;
} else {
*glDesc = &gl_info->gl_formats[idx];
@@ -1125,6 +1154,55 @@ const char *debug_d3ddegree(WINED3DDEGREETYPE degree) {
}
}
const char *debug_fixup_channel_source(enum fixup_channel_source source)
{
switch(source)
{
#define WINED3D_TO_STR(x) case x: return #x
WINED3D_TO_STR(CHANNEL_SOURCE_ZERO);
WINED3D_TO_STR(CHANNEL_SOURCE_ONE);
WINED3D_TO_STR(CHANNEL_SOURCE_X);
WINED3D_TO_STR(CHANNEL_SOURCE_Y);
WINED3D_TO_STR(CHANNEL_SOURCE_Z);
WINED3D_TO_STR(CHANNEL_SOURCE_W);
WINED3D_TO_STR(CHANNEL_SOURCE_YUV0);
WINED3D_TO_STR(CHANNEL_SOURCE_YUV1);
#undef WINED3D_TO_STR
default:
FIXME("Unrecognized fixup_channel_source %#x\n", source);
return "unrecognized";
}
}
const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup)
{
switch(yuv_fixup)
{
#define WINED3D_TO_STR(x) case x: return #x
WINED3D_TO_STR(YUV_FIXUP_YUY2);
WINED3D_TO_STR(YUV_FIXUP_UYVY);
WINED3D_TO_STR(YUV_FIXUP_YV12);
#undef WINED3D_TO_STR
default:
FIXME("Unrecognized YUV fixup %#x\n", yuv_fixup);
return "unrecognized";
}
}
void dump_color_fixup_desc(struct color_fixup_desc fixup)
{
if (is_yuv_fixup(fixup))
{
TRACE("\tYUV: %s\n", debug_yuv_fixup(get_yuv_fixup(fixup)));
return;
}
TRACE("\tX: %s%s\n", debug_fixup_channel_source(fixup.x_source), fixup.x_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tY: %s%s\n", debug_fixup_channel_source(fixup.y_source), fixup.y_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tZ: %s%s\n", debug_fixup_channel_source(fixup.z_source), fixup.z_sign_fixup ? ", SIGN_FIXUP" : "");
TRACE("\tW: %s%s\n", debug_fixup_channel_source(fixup.w_source), fixup.w_sign_fixup ? ", SIGN_FIXUP" : "");
}
/*****************************************************************************
* Useful functions mapping GL <-> D3D values
*/
@@ -1633,7 +1711,8 @@ void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *val
HeapFree(GetProcessHeap(), 0, table);
}
static inline struct hash_table_entry_t *hash_table_get_by_idx(struct hash_table_t *table, void *key, unsigned int idx)
static inline struct hash_table_entry_t *hash_table_get_by_idx(const struct hash_table_t *table, const void *key,
unsigned int idx)
{
struct hash_table_entry_t *entry;
@@ -1781,7 +1860,7 @@ void hash_table_remove(struct hash_table_t *table, void *key)
hash_table_put(table, key, NULL);
}
void *hash_table_get(struct hash_table_t *table, void *key)
void *hash_table_get(const struct hash_table_t *table, const void *key)
{
unsigned int idx;
struct hash_table_entry_t *entry;
@@ -1838,7 +1917,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
settings->op[i].aop = WINED3DTOP_DISABLE;
settings->op[i].carg0 = settings->op[i].carg1 = settings->op[i].carg2 = ARG_UNUSED;
settings->op[i].aarg0 = settings->op[i].aarg1 = settings->op[i].aarg2 = ARG_UNUSED;
settings->op[i].color_correction = WINED3DFMT_UNKNOWN;
settings->op[i].color_correction = COLOR_FIXUP_IDENTITY;
settings->op[i].dst = resultreg;
settings->op[i].tex_type = tex_1d;
settings->op[i].projected = proj_none;
@@ -1848,7 +1927,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
texture = (IWineD3DBaseTextureImpl *) stateblock->textures[i];
if(texture) {
settings->op[i].color_correction = texture->baseTexture.shader_conversion_group;
settings->op[i].color_correction = texture->baseTexture.shader_color_fixup;
if(ignore_textype) {
settings->op[i].tex_type = tex_1d;
} else {
@@ -1871,7 +1950,7 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
}
}
} else {
settings->op[i].color_correction = WINED3DFMT_UNKNOWN;
settings->op[i].color_correction = COLOR_FIXUP_IDENTITY;
settings->op[i].tex_type = tex_1d;
}
@@ -2013,9 +2092,11 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting
}
#undef GLINFO_LOCATION
struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders, struct ffp_frag_settings *settings)
const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
const struct ffp_frag_settings *settings)
{
return (struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);}
return (const struct ffp_frag_desc *)hash_table_get(fragment_shaders, settings);
}
void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc) {
struct ffp_frag_settings *key = HeapAlloc(GetProcessHeap(), 0, sizeof(*key));
@@ -2121,10 +2202,11 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DCont
}
#undef GLINFO_LOCATION
unsigned int ffp_frag_program_key_hash(void *key) {
struct ffp_frag_settings *k = (struct ffp_frag_settings *)key;
unsigned int ffp_frag_program_key_hash(const void *key)
{
const struct ffp_frag_settings *k = (const struct ffp_frag_settings *)key;
unsigned int hash = 0, i;
DWORD *blob;
const DWORD *blob;
/* This takes the texture op settings of stage 0 and 1 into account.
* how exactly depends on the memory laybout of the compiler, but it
@@ -2133,7 +2215,7 @@ unsigned int ffp_frag_program_key_hash(void *key) {
* the ffp setup has distinct stage 0 and 1 settings.
*/
for(i = 0; i < 2; i++) {
blob = (DWORD *) &k->op[i];
blob = (const DWORD *)&k->op[i];
hash ^= blob[0] ^ blob[1];
}
@@ -2147,9 +2229,10 @@ unsigned int ffp_frag_program_key_hash(void *key) {
return hash;
}
BOOL ffp_frag_program_key_compare(void *keya, void *keyb) {
struct ffp_frag_settings *ka = (struct ffp_frag_settings *)keya;
struct ffp_frag_settings *kb = (struct ffp_frag_settings *)keyb;
BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb)
{
const struct ffp_frag_settings *ka = (const struct ffp_frag_settings *)keya;
const struct ffp_frag_settings *kb = (const struct ffp_frag_settings *)keyb;
return memcmp(ka, kb, sizeof(*ka)) == 0;
}
+18 -20
View File
@@ -72,7 +72,7 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
LEAVE_GL();
}
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@@ -82,27 +82,27 @@ static ULONG WINAPI IWineD3DVertexBufferImpl_Release(IWineD3DVertexBuffer *iface
IWineD3DVertexBuffer IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetDevice(IWineD3DVertexBuffer *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DVertexBufferImpl_SetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetPrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DVertexBufferImpl_FreePrivateData(IWineD3DVertexBuffer *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DVertexBufferImpl_SetPriority(IWineD3DVertexBuffer *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DVertexBufferImpl_GetPriority(IWineD3DVertexBuffer *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static inline void fixup_d3dcolor(DWORD *pos) {
@@ -143,7 +143,8 @@ static inline void fixup_transformed_pos(float *p) {
p[3] = w;
}
DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, WineDirect3DVertexStridedData *strided, DWORD stride) {
static DWORD *find_conversion_shift(IWineD3DVertexBufferImpl *This, const WineDirect3DVertexStridedData *strided, DWORD stride)
{
DWORD *ret, i, shift, j, type;
DWORD orig_type_size;
@@ -279,7 +280,7 @@ static inline BOOL check_attribute(IWineD3DVertexBufferImpl *This, const WineDir
return ret;
}
inline BOOL WINAPI IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This)
static inline BOOL IWineD3DVertexBufferImpl_FindDecl(IWineD3DVertexBufferImpl *This)
{
IWineD3DDeviceImpl *device = This->resource.wineD3DDevice;
BOOL ret = FALSE;
@@ -622,7 +623,7 @@ static void WINAPI IWineD3DVertexBufferImpl_PreLoad(IWineD3DVertexBuffer *if
case CONV_FLOAT16_2:
{
float *out = (float *) (&data[This->conv_stride * i + j + This->conv_shift[j]]);
WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
const WORD *in = (WORD *) (&This->resource.allocatedMemory[i * This->stride + j]);
out[1] = float_16_to_32(in + 1);
out[0] = float_16_to_32(in + 0);
@@ -703,11 +704,11 @@ static void WINAPI IWineD3DVertexBufferImpl_UnLoad(IWineD3DVertexBuffer *iface)
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVertexBufferImpl_GetType(IWineD3DVertexBuffer *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
static HRESULT WINAPI IWineD3DVertexBufferImpl_GetParent(IWineD3DVertexBuffer *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
@@ -743,7 +744,7 @@ static HRESULT WINAPI IWineD3DVertexBufferImpl_Lock(IWineD3DVertexBuffer *iface
/* TODO: check Flags compatibility with This->currentDesc.Usage (see MSDN) */
return WINED3D_OK;
}
HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
static HRESULT WINAPI IWineD3DVertexBufferImpl_Unlock(IWineD3DVertexBuffer *iface) {
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *) iface;
LONG lockcount;
TRACE("(%p)\n", This);
@@ -796,7 +797,8 @@ const IWineD3DVertexBufferVtbl IWineD3DVertexBuffer_Vtbl =
IWineD3DVertexBufferImpl_GetDesc
};
BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo) {
const BYTE* IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo)
{
IWineD3DVertexBufferImpl *This = (IWineD3DVertexBufferImpl *)iface;
*vbo = This->vbo;
@@ -806,15 +808,11 @@ BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWO
This->Flags &= ~VBFLAG_CREATEVBO;
if(This->vbo) {
*vbo = This->vbo;
return (BYTE *) iOffset;
return (const BYTE *)iOffset;
}
}
return This->resource.allocatedMemory + iOffset;
} else {
return (BYTE *) iOffset;
return (const BYTE *)iOffset;
}
}
HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface) {
return WINED3D_OK;
}
@@ -316,11 +316,9 @@ static inline void find_swizzled_attribs(IWineD3DVertexDeclaration *declaration,
}
/** Generate a vertex shader string using either GL_VERTEX_PROGRAM_ARB
or GLSL and send it to the card */
static VOID IWineD3DVertexShaderImpl_GenerateShader(
IWineD3DVertexShader *iface,
shader_reg_maps* reg_maps,
CONST DWORD *pFunction) {
static void IWineD3DVertexShaderImpl_GenerateShader(IWineD3DVertexShader *iface,
const struct shader_reg_maps* reg_maps, const DWORD *pFunction)
{
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
IWineD3DVertexDeclaration *decl = ((IWineD3DDeviceImpl *) This->baseShader.device)->stateBlock->vertexDecl;
SHADER_BUFFER buffer;
@@ -485,7 +483,7 @@ static void WINAPI IWineD3DVertexShaderImpl_FakeSemantics(IWineD3DVertexShader *
int i;
for (i = 0; i < vdecl->declarationWNumElements - 1; ++i) {
WINED3DVERTEXELEMENT* element = vdecl->pDeclarationWine + i;
const WINED3DVERTEXELEMENT *element = vdecl->pDeclarationWine + i;
vshader_set_input(This, element->Reg, element->Usage, element->UsageIndex);
}
}
@@ -563,7 +561,7 @@ static inline BOOL swizzled_attribs_differ(IWineD3DVertexShaderImpl *This, IWine
return FALSE;
}
static HRESULT WINAPI IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface) {
IWineD3DVertexShaderImpl *This = (IWineD3DVertexShaderImpl *)iface;
IWineD3DVertexDeclarationImpl *vdecl;
CONST DWORD *function = This->baseShader.function;
@@ -626,7 +624,6 @@ const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl =
IWineD3DVertexShaderImpl_GetParent,
/*** IWineD3DBaseShader methods ***/
IWineD3DVertexShaderImpl_SetFunction,
IWineD3DVertexShaderImpl_CompileShader,
/*** IWineD3DVertexShader methods ***/
IWineD3DVertexShaderImpl_GetDevice,
IWineD3DVertexShaderImpl_GetFunction,
+11 -11
View File
@@ -94,7 +94,7 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
TRACE("(%p) : Releasing from %d\n", This, This->resource.ref);
ref = InterlockedDecrement(&This->resource.ref);
if (ref == 0) {
IWineD3DResourceImpl_CleanUp((IWineD3DResource *)iface);
resource_cleanup((IWineD3DResource *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
return ref;
@@ -104,35 +104,35 @@ static ULONG WINAPI IWineD3DVolumeImpl_Release(IWineD3DVolume *iface) {
IWineD3DVolume IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DVolumeImpl_GetParent(IWineD3DVolume *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
static HRESULT WINAPI IWineD3DVolumeImpl_GetDevice(IWineD3DVolume *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DVolumeImpl_SetPrivateData(IWineD3DVolume *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DVolumeImpl_GetPrivateData(IWineD3DVolume *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DVolumeImpl_FreePrivateData(IWineD3DVolume *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DVolumeImpl_SetPriority(IWineD3DVolume *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DVolumeImpl_GetPriority(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DVolumeImpl_PreLoad(IWineD3DVolume *iface) {
IWineD3DResourceImpl_PreLoad((IWineD3DResource *)iface);
FIXME("iface %p stub!\n", iface);
}
static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
@@ -143,7 +143,7 @@ static void WINAPI IWineD3DVolumeImpl_UnLoad(IWineD3DVolume *iface) {
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeImpl_GetType(IWineD3DVolume *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
/* *******************************************
@@ -310,7 +310,7 @@ static HRESULT WINAPI IWineD3DVolumeImpl_SetContainer(IWineD3DVolume *iface, IWi
static HRESULT WINAPI IWineD3DVolumeImpl_LoadTexture(IWineD3DVolume *iface, int gl_level, BOOL srgb_mode) {
IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface;
WINED3DFORMAT format = This->resource.format;
const GlPixelFormatDesc *glDesc;
const struct GlPixelFormatDesc *glDesc;
getFormatDescEntry(format, &GLINFO_LOCATION, &glDesc);
TRACE("(%p) : level %u, format %s (0x%08x)\n", This, gl_level, debug_d3dformat(format), format);
@@ -67,27 +67,27 @@ static ULONG WINAPI IWineD3DVolumeTextureImpl_Release(IWineD3DVolumeTexture *ifa
IWineD3DVolumeTexture IWineD3DResource parts follow
**************************************************** */
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetDevice(IWineD3DVolumeTexture *iface, IWineD3DDevice** ppDevice) {
return IWineD3DResourceImpl_GetDevice((IWineD3DResource *)iface, ppDevice);
return resource_get_device((IWineD3DResource *)iface, ppDevice);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, CONST void* pData, DWORD SizeOfData, DWORD Flags) {
return IWineD3DResourceImpl_SetPrivateData((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
return resource_set_private_data((IWineD3DResource *)iface, refguid, pData, SizeOfData, Flags);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetPrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid, void* pData, DWORD* pSizeOfData) {
return IWineD3DResourceImpl_GetPrivateData((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
return resource_get_private_data((IWineD3DResource *)iface, refguid, pData, pSizeOfData);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_FreePrivateData(IWineD3DVolumeTexture *iface, REFGUID refguid) {
return IWineD3DResourceImpl_FreePrivateData((IWineD3DResource *)iface, refguid);
return resource_free_private_data((IWineD3DResource *)iface, refguid);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetPriority(IWineD3DVolumeTexture *iface, DWORD PriorityNew) {
return IWineD3DResourceImpl_SetPriority((IWineD3DResource *)iface, PriorityNew);
return resource_set_priority((IWineD3DResource *)iface, PriorityNew);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetPriority(IWineD3DVolumeTexture *iface) {
return IWineD3DResourceImpl_GetPriority((IWineD3DResource *)iface);
return resource_get_priority((IWineD3DResource *)iface);
}
static void WINAPI IWineD3DVolumeTextureImpl_PreLoad(IWineD3DVolumeTexture *iface) {
@@ -145,57 +145,57 @@ static void WINAPI IWineD3DVolumeTextureImpl_UnLoad(IWineD3DVolumeTexture *iface
IWineD3DVolume_UnLoad(This->volumes[i]);
}
IWineD3DBaseTextureImpl_UnLoad((IWineD3DBaseTexture *) iface);
basetexture_unload((IWineD3DBaseTexture *)iface);
}
static WINED3DRESOURCETYPE WINAPI IWineD3DVolumeTextureImpl_GetType(IWineD3DVolumeTexture *iface) {
return IWineD3DResourceImpl_GetType((IWineD3DResource *)iface);
return resource_get_type((IWineD3DResource *)iface);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_GetParent(IWineD3DVolumeTexture *iface, IUnknown **pParent) {
return IWineD3DResourceImpl_GetParent((IWineD3DResource *)iface, pParent);
return resource_get_parent((IWineD3DResource *)iface, pParent);
}
/* ******************************************************
IWineD3DVolumeTexture IWineD3DBaseTexture parts follow
****************************************************** */
static DWORD WINAPI IWineD3DVolumeTextureImpl_SetLOD(IWineD3DVolumeTexture *iface, DWORD LODNew) {
return IWineD3DBaseTextureImpl_SetLOD((IWineD3DBaseTexture *)iface, LODNew);
return basetexture_set_lod((IWineD3DBaseTexture *)iface, LODNew);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLOD(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLOD((IWineD3DBaseTexture *)iface);
return basetexture_get_lod((IWineD3DBaseTexture *)iface);
}
static DWORD WINAPI IWineD3DVolumeTextureImpl_GetLevelCount(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetLevelCount((IWineD3DBaseTexture *)iface);
return basetexture_get_level_count((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_SetAutoGenFilterType(IWineD3DVolumeTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType) {
return IWineD3DBaseTextureImpl_SetAutoGenFilterType((IWineD3DBaseTexture *)iface, FilterType);
return basetexture_set_autogen_filter_type((IWineD3DBaseTexture *)iface, FilterType);
}
static WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DVolumeTextureImpl_GetAutoGenFilterType(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetAutoGenFilterType((IWineD3DBaseTexture *)iface);
return basetexture_get_autogen_filter_type((IWineD3DBaseTexture *)iface);
}
static void WINAPI IWineD3DVolumeTextureImpl_GenerateMipSubLevels(IWineD3DVolumeTexture *iface) {
IWineD3DBaseTextureImpl_GenerateMipSubLevels((IWineD3DBaseTexture *)iface);
basetexture_generate_mipmaps((IWineD3DBaseTexture *)iface);
}
/* Internal function, No d3d mapping */
static BOOL WINAPI IWineD3DVolumeTextureImpl_SetDirty(IWineD3DVolumeTexture *iface, BOOL dirty) {
return IWineD3DBaseTextureImpl_SetDirty((IWineD3DBaseTexture *)iface, dirty);
return basetexture_set_dirty((IWineD3DBaseTexture *)iface, dirty);
}
static BOOL WINAPI IWineD3DVolumeTextureImpl_GetDirty(IWineD3DVolumeTexture *iface) {
return IWineD3DBaseTextureImpl_GetDirty((IWineD3DBaseTexture *)iface);
return basetexture_get_dirty((IWineD3DBaseTexture *)iface);
}
static HRESULT WINAPI IWineD3DVolumeTextureImpl_BindTexture(IWineD3DVolumeTexture *iface) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : relay to BaseTexture\n", This);
return IWineD3DBaseTextureImpl_BindTexture((IWineD3DBaseTexture *)iface);
return basetexture_bind((IWineD3DBaseTexture *)iface);
}
static UINT WINAPI IWineD3DVolumeTextureImpl_GetTextureDimensions(IWineD3DVolumeTexture *iface) {
@@ -216,7 +216,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_ApplyStateChanges(IWineD3DVolumeTex
const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]) {
IWineD3DVolumeTextureImpl *This = (IWineD3DVolumeTextureImpl *)iface;
TRACE("(%p) : nothing to do, passing to base texture\n", This);
IWineD3DBaseTextureImpl_ApplyStateChanges((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
basetexture_apply_state_changes((IWineD3DBaseTexture *)iface, textureStates, samplerStates);
}
@@ -234,7 +234,7 @@ static void WINAPI IWineD3DVolumeTextureImpl_Destroy(IWineD3DVolumeTexture *ifac
D3DCB_DestroyVolume(This->volumes[i]);
}
}
IWineD3DBaseTextureImpl_CleanUp((IWineD3DBaseTexture *) iface);
basetexture_cleanup((IWineD3DBaseTexture *)iface);
HeapFree(GetProcessHeap(), 0, This);
}
File diff suppressed because it is too large Load Diff
@@ -4,6 +4,7 @@
<importlibrary definition="wined3d.def" />
<include base="wined3d">.</include>
<include base="ReactOS">include/reactos/wine</include>
<include base="wined3d" root="intermediate">.</include>
<define name="__WINESRC__" />
<define name="USE_WIN32_OPENGL" />
@@ -49,4 +50,8 @@
<file>volumetexture.c</file>
<file>wined3d_main.c</file>
<file>version.rc</file>
<dependency>wined3d_header</dependency>
</module>
<module name="wined3d_header" type="idlheader" allowwarnings="true">
<file>wined3d.idl</file>
</module>
File diff suppressed because it is too large Load Diff
@@ -43,6 +43,8 @@ wined3d_settings_t wined3d_settings =
TRUE, /* Use of GLSL enabled by default */
ORM_BACKBUFFER, /* Use the backbuffer to do offscreen rendering */
RTL_AUTO, /* Automatically determine best locking method */
PCI_VENDOR_NONE,/* PCI Vendor ID */
PCI_DEVICE_NONE,/* PCI Device ID */
0, /* The default of memory is set in FillGLCaps */
NULL, /* No wine logo by default */
FALSE /* Disable multisampling for now due to Nvidia driver bugs which happens for some users */
@@ -77,6 +79,15 @@ static inline DWORD get_config_key(HKEY defkey, HKEY appkey, const char* name, c
return ERROR_FILE_NOT_FOUND;
}
static inline DWORD get_config_key_dword(HKEY defkey, HKEY appkey, const char* name, DWORD *data)
{
DWORD type;
DWORD size = sizeof(DWORD);
if (0 != appkey && !RegQueryValueExA( appkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
if (0 != defkey && !RegQueryValueExA( defkey, name, 0, &type, (LPBYTE) data, &size ) && (type == REG_DWORD)) return 0;
return ERROR_FILE_NOT_FOUND;
}
static void wined3d_do_nothing(void)
{
}
@@ -92,7 +103,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
DWORD size = sizeof(buffer);
HKEY hkey = 0;
HKEY appkey = 0;
DWORD len;
DWORD len, tmpvalue;
WNDCLASSA wc;
/* We need our own window class for a fake window which we use to retrieve GL capabilities */
@@ -238,6 +249,36 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv)
wined3d_settings.rendertargetlock_mode = RTL_TEXTEX;
}
}
if ( !get_config_key_dword( hkey, appkey, "VideoPciDeviceID", &tmpvalue) )
{
int pci_device_id = tmpvalue;
/* A pci device id is 16-bit */
if(pci_device_id > 0xffff)
{
ERR("Invalid value for VideoPciDeviceID. The value should be smaller or equal to 65535 or 0xffff\n");
}
else
{
TRACE("Using PCI Device ID %04x\n", pci_device_id);
wined3d_settings.pci_device_id = pci_device_id;
}
}
if ( !get_config_key_dword( hkey, appkey, "VideoPciVendorID", &tmpvalue) )
{
int pci_vendor_id = tmpvalue;
/* A pci device id is 16-bit */
if(pci_vendor_id > 0xffff)
{
ERR("Invalid value for VideoPciVendorID. The value should be smaller or equal to 65535 or 0xffff\n");
}
else
{
TRACE("Using PCI Vendor ID %04x\n", pci_vendor_id);
wined3d_settings.pci_vendor_id = pci_vendor_id;
}
}
if ( !get_config_key( hkey, appkey, "VideoMemorySize", buffer, size) )
{
int TmpVideoMemorySize = atoi(buffer);
+246 -188
View File
@@ -37,15 +37,99 @@
#include "wine/debug.h"
#include "wine/unicode.h"
#include "objbase.h"
#include "wined3d_private_types.h"
#include "wine/wined3d_interface.h"
#include "wine/wined3d_caps.h"
#include "wined3d.h"
#include "wined3d_gl.h"
#include "wine/list.h"
/* Texture format fixups */
enum fixup_channel_source
{
CHANNEL_SOURCE_ZERO = 0,
CHANNEL_SOURCE_ONE = 1,
CHANNEL_SOURCE_X = 2,
CHANNEL_SOURCE_Y = 3,
CHANNEL_SOURCE_Z = 4,
CHANNEL_SOURCE_W = 5,
CHANNEL_SOURCE_YUV0 = 6,
CHANNEL_SOURCE_YUV1 = 7,
};
enum yuv_fixup
{
YUV_FIXUP_YUY2 = 0,
YUV_FIXUP_UYVY = 1,
YUV_FIXUP_YV12 = 2,
};
#include <pshpack2.h>
struct color_fixup_desc
{
unsigned x_sign_fixup : 1;
unsigned x_source : 3;
unsigned y_sign_fixup : 1;
unsigned y_source : 3;
unsigned z_sign_fixup : 1;
unsigned z_source : 3;
unsigned w_sign_fixup : 1;
unsigned w_source : 3;
};
#include <poppack.h>
static const struct color_fixup_desc COLOR_FIXUP_IDENTITY =
{0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_Z, 0, CHANNEL_SOURCE_W};
static inline struct color_fixup_desc create_color_fixup_desc(
int sign0, enum fixup_channel_source src0, int sign1, enum fixup_channel_source src1,
int sign2, enum fixup_channel_source src2, int sign3, enum fixup_channel_source src3)
{
struct color_fixup_desc fixup =
{
sign0, src0,
sign1, src1,
sign2, src2,
sign3, src3,
};
return fixup;
}
static inline struct color_fixup_desc create_yuv_fixup_desc(enum yuv_fixup yuv_fixup)
{
struct color_fixup_desc fixup =
{
0, yuv_fixup & (1 << 0) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
0, yuv_fixup & (1 << 1) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
0, yuv_fixup & (1 << 2) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
0, yuv_fixup & (1 << 3) ? CHANNEL_SOURCE_YUV1 : CHANNEL_SOURCE_YUV0,
};
return fixup;
}
static inline BOOL is_identity_fixup(struct color_fixup_desc fixup)
{
return !memcmp(&fixup, &COLOR_FIXUP_IDENTITY, sizeof(fixup));
}
static inline BOOL is_yuv_fixup(struct color_fixup_desc fixup)
{
return fixup.x_source == CHANNEL_SOURCE_YUV0 || fixup.x_source == CHANNEL_SOURCE_YUV1;
}
static inline enum yuv_fixup get_yuv_fixup(struct color_fixup_desc fixup)
{
enum yuv_fixup yuv_fixup = 0;
if (fixup.x_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 0);
if (fixup.y_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 1);
if (fixup.z_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 2);
if (fixup.w_source == CHANNEL_SOURCE_YUV1) yuv_fixup |= (1 << 3);
return yuv_fixup;
}
/* Hash table functions */
typedef unsigned int (hash_function_t)(void *key);
typedef BOOL (compare_function_t)(void *keya, void *keyb);
typedef unsigned int (hash_function_t)(const void *key);
typedef BOOL (compare_function_t)(const void *keya, const void *keyb);
#define ceilf(x) (float)ceil((double)x)
@@ -71,7 +155,7 @@ struct hash_table_t {
struct hash_table_t *hash_table_create(hash_function_t *hash_function, compare_function_t *compare_function);
void hash_table_destroy(struct hash_table_t *table, void (*free_value)(void *value, void *cb), void *cb);
void *hash_table_get(struct hash_table_t *table, void *key);
void *hash_table_get(const struct hash_table_t *table, const void *key);
void hash_table_put(struct hash_table_t *table, void *key, void *value);
void hash_table_remove(struct hash_table_t *table, void *key);
@@ -109,17 +193,22 @@ typedef enum _WINELOOKUP {
MAX_LOOKUPS = 1
} WINELOOKUP;
extern int minLookup[MAX_LOOKUPS];
extern int maxLookup[MAX_LOOKUPS];
extern const int minLookup[MAX_LOOKUPS];
extern const int maxLookup[MAX_LOOKUPS];
extern DWORD *stateLookup[MAX_LOOKUPS];
typedef DWORD magLookup_t[WINED3DTEXF_ANISOTROPIC + 1];
extern magLookup_t magLookup;
extern magLookup_t magLookup_noFilter;
struct min_lookup
{
GLenum mip[WINED3DTEXF_LINEAR + 1];
};
typedef DWORD minMipLookup_t[WINED3DTEXF_ANISOTROPIC + 1][WINED3DTEXF_LINEAR + 1];
extern minMipLookup_t minMipLookup;
extern minMipLookup_t minMipLookup_noFilter;
struct min_lookup minMipLookup[WINED3DTEXF_ANISOTROPIC + 1];
const struct min_lookup minMipLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
GLenum magLookup[WINED3DTEXF_ANISOTROPIC + 1];
const GLenum magLookup_noFilter[WINED3DTEXF_ANISOTROPIC + 1];
extern const struct filter_lookup filter_lookup_nofilter;
extern struct filter_lookup filter_lookup;
void init_type_lookup(WineD3D_GL_Info *gl_info);
#define WINED3D_ATR_TYPE(type) GLINFO_LOCATION.glTypeLookup[type].d3dType
@@ -187,6 +276,9 @@ static inline float float_16_to_32(const unsigned short *in) {
#define RTL_TEXDRAW 3
#define RTL_TEXTEX 4
#define PCI_VENDOR_NONE 0xffff /* e.g. 0x8086 for Intel and 0x10de for Nvidia */
#define PCI_DEVICE_NONE 0xffff /* e.g. 0x14f for a Geforce6200 */
/* NOTE: When adding fields to this structure, make sure to update the default
* values in wined3d_main.c as well. */
typedef struct wined3d_settings_s {
@@ -200,6 +292,8 @@ typedef struct wined3d_settings_s {
BOOL glslRequested;
int offscreen_rendering_mode;
int rendertargetlock_mode;
unsigned short pci_vendor_id;
unsigned short pci_device_id;
/* Memory tracking and object counting */
unsigned int emulated_textureram;
char *logo;
@@ -307,7 +401,7 @@ enum WINED3D_SHADER_INSTRUCTION_HANDLER
WINED3DSIH_TABLE_SIZE
};
typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
typedef void (*SHADER_HANDLER)(const struct SHADER_OPCODE_ARG *);
struct shader_caps {
DWORD VertexShaderVersion;
@@ -342,15 +436,15 @@ typedef struct {
void (*shader_deselect_depth_blt)(IWineD3DDevice *iface);
void (*shader_load_constants)(IWineD3DDevice *iface, char usePS, char useVS);
void (*shader_cleanup)(IWineD3DDevice *iface);
void (*shader_color_correction)(struct SHADER_OPCODE_ARG *arg);
void (*shader_color_correction)(const struct SHADER_OPCODE_ARG *arg, struct color_fixup_desc fixup);
void (*shader_destroy)(IWineD3DBaseShader *iface);
HRESULT (*shader_alloc_private)(IWineD3DDevice *iface);
void (*shader_free_private)(IWineD3DDevice *iface);
BOOL (*shader_dirtifyable_constants)(IWineD3DDevice *iface);
void (*shader_generate_pshader)(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer);
GLuint (*shader_generate_pshader)(IWineD3DPixelShader *iface, SHADER_BUFFER *buffer);
void (*shader_generate_vshader)(IWineD3DVertexShader *iface, SHADER_BUFFER *buffer);
void (*shader_get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct shader_caps *caps);
BOOL (*shader_conv_supported)(WINED3DFORMAT conv);
void (*shader_get_caps)(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct shader_caps *caps);
BOOL (*shader_color_fixup_supported)(struct color_fixup_desc fixup);
} shader_backend_t;
extern const shader_backend_t glsl_shader_backend;
@@ -394,11 +488,12 @@ extern int num_lock;
#define D3DCOLOR_B(dw) (((float) (((dw) >> 0) & 0xFF)) / 255.0f)
#define D3DCOLOR_A(dw) (((float) (((dw) >> 24) & 0xFF)) / 255.0f)
#define D3DCOLORTOGLFLOAT4(dw, vec) \
#define D3DCOLORTOGLFLOAT4(dw, vec) do { \
(vec)[0] = D3DCOLOR_R(dw); \
(vec)[1] = D3DCOLOR_G(dw); \
(vec)[2] = D3DCOLOR_B(dw); \
(vec)[3] = D3DCOLOR_A(dw);
(vec)[3] = D3DCOLOR_A(dw); \
} while(0)
/* DirectX Device Limits */
/* --------------------- */
@@ -412,8 +507,9 @@ extern int num_lock;
/* Checking of API calls */
/* --------------------- */
#ifndef WINE_NO_DEBUG_MSGS
#define checkGLcall(A) \
{ \
do { \
GLint err = glGetError(); \
if (err == GL_NO_ERROR) { \
TRACE("%s call ok %s / %d\n", A, __FILE__, __LINE__); \
@@ -423,7 +519,10 @@ extern int num_lock;
debug_glerror(err), err, A, __FILE__, __LINE__); \
err = glGetError(); \
} while (err != GL_NO_ERROR); \
}
} while(0)
#else
#define checkGLcall(A) do {} while(0)
#endif
/* Trace routines / diagnostics */
/* ---------------------------- */
@@ -440,13 +539,13 @@ do {
/* Macro to dump out the current state of the light chain */
#define DUMP_LIGHT_CHAIN() \
{ \
do { \
PLIGHTINFOEL *el = This->stateBlock->lights;\
while (el) { \
TRACE("Light %p (glIndex %ld, d3dIndex %ld, enabled %d)\n", el, el->glIndex, el->OriginalIndex, el->lightEnabled);\
el = el->next; \
} \
}
} while(0)
/* Trace vector and strided data information */
#define TRACE_VECTOR(name) TRACE( #name "=(%f, %f, %f, %f)\n", name.x, name.y, name.z, name.w);
@@ -479,21 +578,6 @@ extern const float identity[16];
# define VTRACE(A)
#endif
/* Checking of per-vertex related GL calls */
/* --------------------- */
#define vcheckGLcall(A) \
{ \
GLint err = glGetError(); \
if (err == GL_NO_ERROR) { \
VTRACE(("%s call ok %s / %d\n", A, __FILE__, __LINE__)); \
\
} else do { \
FIXME(">>>>>>>>>>>>>>>>> %s (%#x) from %s @ %s / %d\n", \
debug_glerror(err), err, A, __FILE__, __LINE__); \
err = glGetError(); \
} while (err != GL_NO_ERROR); \
}
/* TODO: Confirm each of these works when wined3d move completed */
#if 0 /* NOTE: Must be 0 in cvs */
/* To avoid having to get gigabytes of trace, the following can be compiled in, and at the start
@@ -548,8 +632,8 @@ void primitiveDeclarationConvertToStridedData(
DWORD get_flexible_vertex_size(DWORD d3dvtVertexType);
typedef void (WINE_GLAPI *glAttribFunc)(void *data);
typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, void *data);
typedef void (WINE_GLAPI *glAttribFunc)(const void *data);
typedef void (WINE_GLAPI *glMultiTexCoordFunc)(GLenum unit, const void *data);
extern glAttribFunc position_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc diffuse_funcs[WINED3DDECLTYPE_UNUSED];
extern glAttribFunc specular_funcs[WINED3DDECLTYPE_UNUSED];
@@ -639,10 +723,10 @@ struct fragment_caps {
struct fragment_pipeline {
void (*enable_extension)(IWineD3DDevice *iface, BOOL enable);
void (*get_caps)(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *caps);
void (*get_caps)(WINED3DDEVTYPE devtype, const WineD3D_GL_Info *gl_info, struct fragment_caps *caps);
HRESULT (*alloc_private)(IWineD3DDevice *iface);
void (*free_private)(IWineD3DDevice *iface);
BOOL (*conv_supported)(WINED3DFORMAT conv);
BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
const struct StateEntryTemplate *states;
BOOL ffp_proj_control;
};
@@ -656,12 +740,9 @@ extern const struct fragment_pipeline nvts_fragment_pipeline;
extern const struct fragment_pipeline nvrc_fragment_pipeline;
/* "Base" state table */
void compile_state_table(struct StateEntry *StateTable,
APPLYSTATEFUNC **dev_multistate_funcs,
WineD3D_GL_Info *gl_info,
const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment,
const struct StateEntryTemplate *misc);
void compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_multistate_funcs,
const WineD3D_GL_Info *gl_info, const struct StateEntryTemplate *vertex,
const struct fragment_pipeline *fragment, const struct StateEntryTemplate *misc);
/* Shaders for color conversions in blits */
struct blit_shader {
@@ -669,7 +750,7 @@ struct blit_shader {
void (*free_private)(IWineD3DDevice *iface);
HRESULT (*set_shader)(IWineD3DDevice *iface, WINED3DFORMAT fmt, GLenum textype, UINT width, UINT height);
void (*unset_shader)(IWineD3DDevice *iface);
BOOL (*conv_supported)(WINED3DFORMAT conv);
BOOL (*color_fixup_supported)(struct color_fixup_desc fixup);
};
extern const struct blit_shader ffp_blit;
@@ -697,6 +778,7 @@ struct WineD3DContext {
BOOL last_was_vshader;
BOOL last_was_foggy_shader;
BOOL namedArraysLoaded, numberedArraysLoaded;
DWORD numbered_array_mask;
BOOL lastWasPow2Texture[MAX_TEXTURES];
GLenum tracking_parm; /* Which source is tracking current colour */
unsigned char num_untracked_materials;
@@ -842,17 +924,24 @@ enum dst_arg
/*****************************************************************************
* Fixed function pipeline replacements
*/
#define ARG_UNUSED 0x3f
struct texture_stage_op
{
unsigned cop : 5, aop : 5;
#define ARG_UNUSED 0x3f
unsigned carg1 : 6, carg2 : 6, carg0 : 6;
unsigned cop : 8;
unsigned carg1 : 8;
unsigned carg2 : 8;
unsigned carg0 : 8;
unsigned aop : 8;
unsigned aarg1 : 8;
unsigned aarg2 : 8;
unsigned aarg0 : 8;
struct color_fixup_desc color_correction;
unsigned tex_type : 3;
unsigned dst : 1; /* Total of 32 bits */
unsigned aarg1 : 6, aarg2 : 6, aarg0 : 6;
unsigned dst : 1;
unsigned projected : 2;
unsigned padding : 12; /* Total of 64 bits */
WINED3DFORMAT color_correction;
unsigned padding : 10;
};
struct ffp_frag_settings {
@@ -873,10 +962,11 @@ struct ffp_frag_desc
};
void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype);
struct ffp_frag_desc *find_ffp_frag_shader(struct hash_table_t *fragment_shaders, struct ffp_frag_settings *settings);
const struct ffp_frag_desc *find_ffp_frag_shader(const struct hash_table_t *fragment_shaders,
const struct ffp_frag_settings *settings);
void add_ffp_frag_shader(struct hash_table_t *shaders, struct ffp_frag_desc *desc);
BOOL ffp_frag_program_key_compare(void *keya, void *keyb);
unsigned int ffp_frag_program_key_hash(void *key);
BOOL ffp_frag_program_key_compare(const void *keya, const void *keyb);
unsigned int ffp_frag_program_key_hash(const void *key);
/*****************************************************************************
* IWineD3D implementation structure
@@ -1033,7 +1123,7 @@ struct IWineD3DDeviceImpl
/* Stream source management */
WineDirect3DVertexStridedData strided_streams;
WineDirect3DVertexStridedData *up_strided;
const WineDirect3DVertexStridedData *up_strided;
BOOL useDrawStridedSlow;
BOOL instancedDraw;
@@ -1072,7 +1162,6 @@ typedef struct PrivateData
GUID tag;
DWORD flags; /* DDSPD_* */
DWORD uniqueness_value;
union
{
@@ -1114,6 +1203,18 @@ typedef struct IWineD3DResourceImpl
IWineD3DResourceClass resource;
} IWineD3DResourceImpl;
void resource_cleanup(IWineD3DResource *iface);
HRESULT resource_free_private_data(IWineD3DResource *iface, REFGUID guid);
HRESULT resource_get_device(IWineD3DResource *iface, IWineD3DDevice **device);
HRESULT resource_get_parent(IWineD3DResource *iface, IUnknown **parent);
DWORD resource_get_priority(IWineD3DResource *iface);
HRESULT resource_get_private_data(IWineD3DResource *iface, REFGUID guid,
void *data, DWORD *data_size);
WINED3DRESOURCETYPE resource_get_type(IWineD3DResource *iface);
DWORD resource_set_priority(IWineD3DResource *iface, DWORD new_priority);
HRESULT resource_set_private_data(IWineD3DResource *iface, REFGUID guid,
const void *data, DWORD data_size, DWORD flags);
/* Tests show that the start address of resources is 32 byte aligned */
#define RESOURCE_ALIGNMENT 32
@@ -1213,20 +1314,20 @@ typedef enum winetexturestates {
*/
typedef struct IWineD3DBaseTextureClass
{
DWORD states[MAX_WINETEXTURESTATES];
UINT levels;
BOOL dirty;
UINT textureName;
float pow2Matrix[16];
UINT LOD;
WINED3DTEXTUREFILTERTYPE filterType;
DWORD states[MAX_WINETEXTURESTATES];
LONG bindCount;
DWORD sampler;
BOOL is_srgb;
UINT srgb_mode_change_count;
WINED3DFORMAT shader_conversion_group;
float pow2Matrix[16];
minMipLookup_t *minMipLookup;
magLookup_t *magLookup;
const struct min_lookup *minMipLookup;
const GLenum *magLookup;
struct color_fixup_desc shader_color_fixup;
} IWineD3DBaseTextureClass;
typedef struct IWineD3DBaseTextureImpl
@@ -1238,6 +1339,21 @@ typedef struct IWineD3DBaseTextureImpl
} IWineD3DBaseTextureImpl;
void basetexture_apply_state_changes(IWineD3DBaseTexture *iface,
const DWORD texture_states[WINED3D_HIGHEST_TEXTURE_STATE + 1],
const DWORD sampler_states[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
HRESULT basetexture_bind(IWineD3DBaseTexture *iface);
void basetexture_cleanup(IWineD3DBaseTexture *iface);
void basetexture_generate_mipmaps(IWineD3DBaseTexture *iface);
WINED3DTEXTUREFILTERTYPE basetexture_get_autogen_filter_type(IWineD3DBaseTexture *iface);
BOOL basetexture_get_dirty(IWineD3DBaseTexture *iface);
DWORD basetexture_get_level_count(IWineD3DBaseTexture *iface);
DWORD basetexture_get_lod(IWineD3DBaseTexture *iface);
HRESULT basetexture_set_autogen_filter_type(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE filter_type);
BOOL basetexture_set_dirty(IWineD3DBaseTexture *iface, BOOL dirty);
DWORD basetexture_set_lod(IWineD3DBaseTexture *iface, DWORD new_lod);
void basetexture_unload(IWineD3DBaseTexture *iface);
/*****************************************************************************
* IWineD3DTexture implementation structure (extends IWineD3DBaseTextureImpl)
*/
@@ -1272,8 +1388,6 @@ typedef struct IWineD3DCubeTextureImpl
/* IWineD3DCubeTexture */
IWineD3DSurface *surfaces[6][MAX_LEVELS];
UINT edgeLength;
} IWineD3DCubeTextureImpl;
extern const IWineD3DCubeTextureVtbl IWineD3DCubeTexture_Vtbl;
@@ -1322,10 +1436,6 @@ typedef struct IWineD3DVolumeTextureImpl
/* IWineD3DVolumeTexture */
IWineD3DVolume *volumes[MAX_LEVELS];
UINT width;
UINT height;
UINT depth;
} IWineD3DVolumeTextureImpl;
extern const IWineD3DVolumeTextureVtbl IWineD3DVolumeTexture_Vtbl;
@@ -1468,24 +1578,26 @@ HRESULT WINAPI IWineD3DBaseSurfaceImpl_IsLost(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Restore(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetPalette(IWineD3DSurface *iface, IWineD3DPalette **Pal);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetPalette(IWineD3DSurface *iface, IWineD3DPalette *Pal);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, WINEDDCOLORKEY *CKey);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetColorKey(IWineD3DSurface *iface, DWORD Flags, const WINEDDCOLORKEY *CKey);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetContainer(IWineD3DSurface *iface, IWineD3DBase *container);
DWORD WINAPI IWineD3DBaseSurfaceImpl_GetPitch(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_RealizePalette(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetOverlayPosition(IWineD3DSurface *iface, LONG X, LONG Y);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetOverlayPosition(IWineD3DSurface *iface, LONG *X, LONG *Y);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlayZOrder(IWineD3DSurface *iface, DWORD Flags, IWineD3DSurface *Ref);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, RECT *SrcRect, IWineD3DSurface *DstSurface, RECT *DstRect, DWORD Flags, WINEDDOVERLAYFX *FX);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_UpdateOverlay(IWineD3DSurface *iface, const RECT *SrcRect,
IWineD3DSurface *DstSurface, const RECT *DstRect, DWORD Flags, const WINEDDOVERLAYFX *FX);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetClipper(IWineD3DSurface *iface, IWineD3DClipper *clipper);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_GetClipper(IWineD3DSurface *iface, IWineD3DClipper **clipper);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_SetFormat(IWineD3DSurface *iface, WINED3DFORMAT format);
HRESULT IWineD3DBaseSurfaceImpl_CreateDIBSection(IWineD3DSurface *iface);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, RECT *DestRect, IWineD3DSurface *SrcSurface, RECT *SrcRect, DWORD Flags, WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty, IWineD3DSurface *Source, RECT *rsrc, DWORD trans);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_Blt(IWineD3DSurface *iface, const RECT *DestRect, IWineD3DSurface *SrcSurface,
const RECT *SrcRect, DWORD Flags, const WINEDDBLTFX *DDBltFx, WINED3DTEXTUREFILTERTYPE Filter);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_BltFast(IWineD3DSurface *iface, DWORD dstx, DWORD dsty,
IWineD3DSurface *Source, const RECT *rsrc, DWORD trans);
HRESULT WINAPI IWineD3DBaseSurfaceImpl_LockRect(IWineD3DSurface *iface, WINED3DLOCKED_RECT* pLockedRect, CONST RECT* pRect, DWORD Flags);
void WINAPI IWineD3DBaseSurfaceImpl_BindTexture(IWineD3DSurface *iface);
const void *WINAPI IWineD3DSurfaceImpl_GetData(IWineD3DSurface *iface);
const void *WINAPI IWineD3DBaseSurfaceImpl_GetData(IWineD3DSurface *iface);
void get_drawable_size_swapchain(IWineD3DSurfaceImpl *This, UINT *width, UINT *height);
void get_drawable_size_backbuffer(IWineD3DSurfaceImpl *This, UINT *width, UINT *height);
@@ -1569,9 +1681,6 @@ typedef enum {
CONVERT_Q8W8V8U8,
CONVERT_V16U16,
CONVERT_A4L4,
CONVERT_R32F,
CONVERT_R16F,
CONVERT_G16R16,
} CONVERT_TYPES;
HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_texturing, GLenum *format, GLenum *internal, GLenum *type, CONVERT_TYPES *convert, int *target_bpp, BOOL srgb_mode);
@@ -1634,12 +1743,12 @@ typedef struct SAVEDSTATES {
BOOL clipplane[MAX_CLIPPLANES];
BOOL vertexDecl;
BOOL pixelShader;
BOOL pixelShaderConstantsB[MAX_CONST_B];
BOOL pixelShaderConstantsI[MAX_CONST_I];
WORD pixelShaderConstantsB;
WORD pixelShaderConstantsI;
BOOL *pixelShaderConstantsF;
BOOL vertexShader;
BOOL vertexShaderConstantsB[MAX_CONST_B];
BOOL vertexShaderConstantsI[MAX_CONST_I];
WORD vertexShaderConstantsB;
WORD vertexShaderConstantsI;
BOOL *vertexShaderConstantsF;
BOOL scissorRect;
} SAVEDSTATES;
@@ -1767,11 +1876,6 @@ extern void stateblock_savedstates_set(
SAVEDSTATES* states,
BOOL value);
extern void stateblock_savedstates_copy(
IWineD3DStateBlock* iface,
SAVEDSTATES* dest,
SAVEDSTATES* source);
extern void stateblock_copy(
IWineD3DStateBlock* destination,
IWineD3DStateBlock* source);
@@ -1859,7 +1963,7 @@ typedef struct IWineD3DSwapChainImpl
extern const IWineD3DSwapChainVtbl IWineD3DSwapChain_Vtbl;
const IWineD3DSwapChainVtbl IWineGDISwapChain_Vtbl;
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, LPRECT rc);
void x11_copy_to_screen(IWineD3DSwapChainImpl *This, const RECT *rc);
HRESULT WINAPI IWineD3DBaseSwapChainImpl_QueryInterface(IWineD3DSwapChain *iface, REFIID riid, LPVOID *ppobj);
ULONG WINAPI IWineD3DBaseSwapChainImpl_AddRef(IWineD3DSwapChain *iface);
@@ -1901,6 +2005,9 @@ const char *debug_glerror(GLenum error);
const char *debug_d3dbasis(WINED3DBASISTYPE basis);
const char *debug_d3ddegree(WINED3DDEGREETYPE order);
const char* debug_d3dtop(WINED3DTEXTUREOP d3dtop);
const char *debug_fixup_channel_source(enum fixup_channel_source source);
const char *debug_yuv_fixup(enum yuv_fixup yuv_fixup);
void dump_color_fixup_desc(struct color_fixup_desc fixup);
/* Routines for GL <-> D3D values */
GLenum StencilOp(DWORD op);
@@ -1933,56 +2040,9 @@ unsigned int count_bits(unsigned int mask);
*
* Note: Only require classes which are subclassed, ie resource, basetexture,
*/
/*** IUnknown methods ***/
extern HRESULT WINAPI IWineD3DResourceImpl_QueryInterface(IWineD3DResource *iface, REFIID riid, void** ppvObject);
extern ULONG WINAPI IWineD3DResourceImpl_AddRef(IWineD3DResource *iface);
extern ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface);
/*** IWineD3DResource methods ***/
extern HRESULT WINAPI IWineD3DResourceImpl_GetParent(IWineD3DResource *iface, IUnknown **pParent);
extern HRESULT WINAPI IWineD3DResourceImpl_GetDevice(IWineD3DResource *iface, IWineD3DDevice ** ppDevice);
extern HRESULT WINAPI IWineD3DResourceImpl_SetPrivateData(IWineD3DResource *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
extern HRESULT WINAPI IWineD3DResourceImpl_GetPrivateData(IWineD3DResource *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
extern HRESULT WINAPI IWineD3DResourceImpl_FreePrivateData(IWineD3DResource *iface, REFGUID refguid);
extern DWORD WINAPI IWineD3DResourceImpl_SetPriority(IWineD3DResource *iface, DWORD PriorityNew);
extern DWORD WINAPI IWineD3DResourceImpl_GetPriority(IWineD3DResource *iface);
extern void WINAPI IWineD3DResourceImpl_PreLoad(IWineD3DResource *iface);
extern void WINAPI IWineD3DResourceImpl_UnLoad(IWineD3DResource *iface);
extern WINED3DRESOURCETYPE WINAPI IWineD3DResourceImpl_GetType(IWineD3DResource *iface);
/*** class static members ***/
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface);
/*** IUnknown methods ***/
extern HRESULT WINAPI IWineD3DBaseTextureImpl_QueryInterface(IWineD3DBaseTexture *iface, REFIID riid, void** ppvObject);
extern ULONG WINAPI IWineD3DBaseTextureImpl_AddRef(IWineD3DBaseTexture *iface);
extern ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface);
/*** IWineD3DResource methods ***/
extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetParent(IWineD3DBaseTexture *iface, IUnknown **pParent);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetDevice(IWineD3DBaseTexture *iface, IWineD3DDevice ** ppDevice);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, CONST void * pData, DWORD SizeOfData, DWORD Flags);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_GetPrivateData(IWineD3DBaseTexture *iface, REFGUID refguid, void * pData, DWORD * pSizeOfData);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_FreePrivateData(IWineD3DBaseTexture *iface, REFGUID refguid);
extern DWORD WINAPI IWineD3DBaseTextureImpl_SetPriority(IWineD3DBaseTexture *iface, DWORD PriorityNew);
extern DWORD WINAPI IWineD3DBaseTextureImpl_GetPriority(IWineD3DBaseTexture *iface);
extern void WINAPI IWineD3DBaseTextureImpl_PreLoad(IWineD3DBaseTexture *iface);
extern void WINAPI IWineD3DBaseTextureImpl_UnLoad(IWineD3DBaseTexture *iface);
extern WINED3DRESOURCETYPE WINAPI IWineD3DBaseTextureImpl_GetType(IWineD3DBaseTexture *iface);
/*** IWineD3DBaseTexture methods ***/
extern DWORD WINAPI IWineD3DBaseTextureImpl_SetLOD(IWineD3DBaseTexture *iface, DWORD LODNew);
extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLOD(IWineD3DBaseTexture *iface);
extern DWORD WINAPI IWineD3DBaseTextureImpl_GetLevelCount(IWineD3DBaseTexture *iface);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_SetAutoGenFilterType(IWineD3DBaseTexture *iface, WINED3DTEXTUREFILTERTYPE FilterType);
extern WINED3DTEXTUREFILTERTYPE WINAPI IWineD3DBaseTextureImpl_GetAutoGenFilterType(IWineD3DBaseTexture *iface);
extern void WINAPI IWineD3DBaseTextureImpl_GenerateMipSubLevels(IWineD3DBaseTexture *iface);
extern BOOL WINAPI IWineD3DBaseTextureImpl_SetDirty(IWineD3DBaseTexture *iface, BOOL);
extern BOOL WINAPI IWineD3DBaseTextureImpl_GetDirty(IWineD3DBaseTexture *iface);
extern BYTE* WINAPI IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
extern HRESULT WINAPI IWineD3DVertexBufferImpl_ReleaseMemory(IWineD3DVertexBuffer* iface);
extern HRESULT WINAPI IWineD3DBaseTextureImpl_BindTexture(IWineD3DBaseTexture *iface);
extern void WINAPI IWineD3DBaseTextureImpl_ApplyStateChanges(IWineD3DBaseTexture *iface, const DWORD textureStates[WINED3D_HIGHEST_TEXTURE_STATE + 1], const DWORD samplerStates[WINED3D_HIGHEST_SAMPLER_STATE + 1]);
/*** class static members ***/
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface);
/* IWineD3DVertexBuffer */
extern const BYTE *IWineD3DVertexBufferImpl_GetMemory(IWineD3DVertexBuffer* iface, DWORD iOffset, GLint *vbo);
/* TODO: Make this dynamic, based on shader limits ? */
#define MAX_REG_ADDR 1
@@ -2060,7 +2120,7 @@ typedef struct SHADER_OPCODE {
typedef struct SHADER_OPCODE_ARG {
IWineD3DBaseShader* shader;
shader_reg_maps* reg_maps;
const shader_reg_maps *reg_maps;
CONST SHADER_OPCODE* opcode;
DWORD opcode_token;
DWORD dst;
@@ -2104,9 +2164,7 @@ extern int shader_addline(
SHADER_BUFFER* buffer,
const char* fmt, ...) PRINTF_ATTR(2,3);
extern const SHADER_OPCODE* shader_get_opcode(
IWineD3DBaseShader *iface,
const DWORD code);
const SHADER_OPCODE *shader_get_opcode(const SHADER_OPCODE *shader_ins, DWORD shader_version, DWORD code);
/* Vertex shader utility functions */
extern BOOL vshader_get_input(
@@ -2121,7 +2179,7 @@ extern BOOL vshader_input_is_color(
extern HRESULT allocate_shader_constants(IWineD3DStateBlockImpl* object);
/* GLSL helper functions */
extern void shader_glsl_add_instruction_modifiers(SHADER_OPCODE_ARG *arg);
extern void shader_glsl_add_instruction_modifiers(const SHADER_OPCODE_ARG *arg);
/*****************************************************************************
* IDirect3DBaseShader implementation structure
@@ -2135,7 +2193,6 @@ typedef struct IWineD3DBaseShaderClass
CONST SHADER_OPCODE *shader_ins;
DWORD *function;
UINT functionLength;
GLuint prgId;
BOOL is_compiled;
UINT cur_loop_depth, cur_loop_regno;
BOOL load_local_constsF;
@@ -2152,12 +2209,6 @@ typedef struct IWineD3DBaseShaderClass
struct list constantsI;
shader_reg_maps reg_maps;
/* Pixel formats of sampled textures, for format conversion. This
* represents the formats found during compilation, it is not initialized
* on the first parser pass. It is needed to check if the shader
* needs recompilation to adjust the format conversion
*/
WINED3DFORMAT sampled_format[MAX_COMBINED_SAMPLERS];
UINT sampled_samplers[MAX_COMBINED_SAMPLERS];
UINT num_sampled_samplers;
@@ -2189,35 +2240,13 @@ extern HRESULT shader_get_registers_used(
CONST DWORD* pToken,
IWineD3DStateBlockImpl *stateBlock);
extern void shader_generate_main(
IWineD3DBaseShader *iface,
SHADER_BUFFER* buffer,
shader_reg_maps* reg_maps,
CONST DWORD* pFunction);
extern void shader_dump_ins_modifiers(
const DWORD output);
extern void shader_dump_param(
IWineD3DBaseShader *iface,
const DWORD param,
const DWORD addr_token,
int input);
extern void shader_generate_main(IWineD3DBaseShader *iface, SHADER_BUFFER *buffer,
const shader_reg_maps *reg_maps, const DWORD *pFunction);
extern void shader_trace_init(
IWineD3DBaseShader *iface,
const DWORD* pFunction);
extern int shader_get_param(
IWineD3DBaseShader* iface,
const DWORD* pToken,
DWORD* param,
DWORD* addr_token);
extern int shader_skip_unrecognized(
IWineD3DBaseShader* iface,
const DWORD* pToken);
static inline int shader_get_regtype(const DWORD param) {
return (((param & WINED3DSP_REGTYPE_MASK) >> WINED3DSP_REGTYPE_SHIFT) |
((param & WINED3DSP_REGTYPE_MASK2) >> WINED3DSP_REGTYPE_SHIFT2));
@@ -2227,8 +2256,6 @@ static inline int shader_get_writemask(const DWORD param) {
return param & WINED3DSP_WRITEMASK_ALL;
}
extern unsigned int shader_get_float_offset(const DWORD reg);
static inline BOOL shader_is_pshader_version(DWORD token) {
return 0xFFFF0000 == (token & 0xFFFF0000);
}
@@ -2302,6 +2329,9 @@ typedef struct IWineD3DVertexShaderImpl {
DWORD usage;
/* The GL shader */
GLuint prgId;
/* Vertex shader input and output semantics */
semantic semantics_in [MAX_ATTRIBS];
semantic semantics_out [MAX_REG_OUTPUT];
@@ -2317,6 +2347,7 @@ typedef struct IWineD3DVertexShaderImpl {
} IWineD3DVertexShaderImpl;
extern const SHADER_OPCODE IWineD3DVertexShaderImpl_shader_ins[];
extern const IWineD3DVertexShaderVtbl IWineD3DVertexShader_Vtbl;
HRESULT IWineD3DVertexShaderImpl_CompileShader(IWineD3DVertexShader *iface);
/*****************************************************************************
* IDirect3DPixelShader implementation structure
@@ -2333,6 +2364,22 @@ struct stb_const_desc {
UINT const_num;
};
/* Stateblock dependent parameters which have to be hardcoded
* into the shader code
*/
struct ps_compile_args {
struct color_fixup_desc color_fixup[MAX_FRAGMENT_SAMPLERS];
BOOL srgb_correction;
enum vertexprocessing_mode vp_mode;
/* Projected textures(ps 1.0-1.3) */
/* Texture types(2D, Cube, 3D) in ps 1.x */
};
struct ps_compiled_shader {
struct ps_compile_args args;
GLuint prgId;
};
typedef struct IWineD3DPixelShaderImpl {
/* IUnknown parts */
const IWineD3DPixelShaderVtbl *lpVtbl;
@@ -2349,22 +2396,21 @@ typedef struct IWineD3DPixelShaderImpl {
BOOL input_reg_used[MAX_REG_INPUT];
int declared_in_count;
/* The GL shader */
struct ps_compiled_shader *gl_shaders;
UINT num_gl_shaders;
/* Some information about the shader behavior */
struct stb_const_desc bumpenvmatconst[MAX_TEXTURES];
char numbumpenvmatconsts;
struct stb_const_desc luminanceconst[MAX_TEXTURES];
char srgb_enabled;
char srgb_mode_hardcoded;
UINT srgb_low_const;
UINT srgb_cmp_const;
char vpos_uniform;
BOOL render_offscreen;
UINT height;
enum vertexprocessing_mode vertexprocessing;
} IWineD3DPixelShaderImpl;
extern const SHADER_OPCODE IWineD3DPixelShaderImpl_shader_ins[];
extern const IWineD3DPixelShaderVtbl IWineD3DPixelShader_Vtbl;
GLuint find_gl_pshader(IWineD3DPixelShaderImpl *shader, const struct ps_compile_args *args);
void find_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWineD3DStateBlockImpl *stateblock, struct ps_compile_args *args);
/* sRGB correction constants */
static const float srgb_cmp = 0.0031308;
@@ -2403,6 +2449,19 @@ extern WINED3DFORMAT pixelformat_for_depth(DWORD depth);
/*****************************************************************************
* Pixel format management
*/
struct GlPixelFormatDesc
{
GLint glInternal;
GLint glGammaInternal;
GLint rtInternal;
GLint glFormat;
GLint glType;
unsigned int Flags;
float heightscale;
struct color_fixup_desc color_fixup;
};
typedef struct {
WINED3DFORMAT format;
DWORD alphaMask, redMask, greenMask, blueMask;
@@ -2412,8 +2471,7 @@ typedef struct {
} StaticPixelFormatDesc;
const StaticPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt,
WineD3D_GL_Info *gl_info,
const GlPixelFormatDesc **glDesc);
const WineD3D_GL_Info *gl_info, const struct GlPixelFormatDesc **glDesc);
static inline BOOL use_vs(IWineD3DDeviceImpl *device) {
return (device->vs_selected_mode != SHADER_NONE