Commit 18857f11 authored by Oliver Stieber's avatar Oliver Stieber Committed by Alexandre Julliard

Add support for samplers.

Switch from using d3d9 constants to wined3d constants so that there's no recursive dependencies.
parent 0713f098
......@@ -69,10 +69,10 @@ ULONG WINAPI IWineD3DBaseTextureImpl_Release(IWineD3DBaseTexture *iface) {
/* class static */
void IWineD3DBaseTextureImpl_CleanUp(IWineD3DBaseTexture *iface) {
IWineD3DBaseTextureImpl *This = (IWineD3DBaseTextureImpl *)iface;
TRACE("(%p) : ", This);
TRACE("(%p) : textureName(%d)\n", This, This->baseTexture.textureName);
if (This->baseTexture.textureName != 0) {
ENTER_GL();
TRACE("Deleting texture %d\n", This->baseTexture.textureName);
TRACE("(%p) : Deleting texture %d\n", This, This->baseTexture.textureName);
glDeleteTextures(1, &This->baseTexture.textureName);
LEAVE_GL();
}
......
......@@ -330,6 +330,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
*/
memset(&gl_info->supported, 0, sizeof(gl_info->supported));
gl_info->max_textures = 1;
gl_info->max_samplers = 1;
gl_info->ps_arb_version = PS_VERSION_NOT_SUPPORTED;
gl_info->vs_arb_version = VS_VERSION_NOT_SUPPORTED;
gl_info->vs_nv_version = VS_VERSION_NOT_SUPPORTED;
......@@ -374,6 +375,9 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
gl_info->ps_arb_version = PS_VERSION_11;
TRACE_(d3d_caps)(" FOUND: ARB Pixel Shader support - version=%02x\n", gl_info->ps_arb_version);
gl_info->supported[ARB_FRAGMENT_PROGRAM] = TRUE;
glGetIntegerv(GL_MAX_TEXTURE_IMAGE_UNITS_ARB, &gl_max);
TRACE_(d3d_caps)(" FOUND: ARB Pixel Shader support - GL_MAX_TEXTURE_IMAGE_UNITS_ARB=%u\n", gl_max);
gl_info->max_samplers = min(16, gl_max);
} else if (strcmp(ThisExtn, "GL_ARB_multisample") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Multisample support\n");
gl_info->supported[ARB_MULTISAMPLE] = TRUE;
......@@ -382,6 +386,7 @@ static BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display)
TRACE_(d3d_caps)(" FOUND: ARB Multitexture support - GL_MAX_TEXTURE_UNITS_ARB=%u\n", gl_max);
gl_info->supported[ARB_MULTITEXTURE] = TRUE;
gl_info->max_textures = min(8, gl_max);
gl_info->max_samplers = max(gl_info->max_samplers, gl_max);
} else if (strcmp(ThisExtn, "GL_ARB_texture_cube_map") == 0) {
TRACE_(d3d_caps)(" FOUND: ARB Texture Cube Map support\n");
gl_info->supported[ARB_TEXTURE_CUBE_MAP] = TRUE;
......
......@@ -61,7 +61,7 @@ ULONG WINAPI IWineD3DResourceImpl_Release(IWineD3DResource *iface) {
/* class static (not in vtable) */
void IWineD3DResourceImpl_CleanUp(IWineD3DResource *iface){
IWineD3DResourceImpl *This = (IWineD3DResourceImpl *)iface;
TRACE("(%p) :", This);
TRACE("(%p) : allocatedMemory(%p)\n", This, This->resource.allocatedMemory);
HeapFree(GetProcessHeap(), 0, This->resource.allocatedMemory);
This->resource.allocatedMemory = 0;
......
......@@ -242,36 +242,47 @@ const char* debug_d3drenderstate(DWORD state) {
}
}
const char* debug_d3dsamplerstate(DWORD state) {
switch (state) {
#define D3DSTATE_TO_STR(u) case u: return #u
D3DSTATE_TO_STR(WINED3DSAMP_BORDERCOLOR );
D3DSTATE_TO_STR(WINED3DSAMP_ADDRESSU );
D3DSTATE_TO_STR(WINED3DSAMP_ADDRESSV );
D3DSTATE_TO_STR(WINED3DSAMP_ADDRESSW );
D3DSTATE_TO_STR(WINED3DSAMP_MAGFILTER );
D3DSTATE_TO_STR(WINED3DSAMP_MINFILTER );
D3DSTATE_TO_STR(WINED3DSAMP_MIPFILTER );
D3DSTATE_TO_STR(WINED3DSAMP_MIPMAPLODBIAS);
D3DSTATE_TO_STR(WINED3DSAMP_MAXMIPLEVEL );
D3DSTATE_TO_STR(WINED3DSAMP_MAXANISOTROPY);
#undef D3DSTATE_TO_STR
default:
FIXME("Unrecognized %lu texture state!\n", state);
return "unrecognized";
}
}
const char* debug_d3dtexturestate(DWORD state) {
switch (state) {
#define D3DSTATE_TO_STR(u) case u: return #u
D3DSTATE_TO_STR(D3DTSS_COLOROP );
D3DSTATE_TO_STR(D3DTSS_COLORARG1 );
D3DSTATE_TO_STR(D3DTSS_COLORARG2 );
D3DSTATE_TO_STR(D3DTSS_ALPHAOP );
D3DSTATE_TO_STR(D3DTSS_ALPHAARG1 );
D3DSTATE_TO_STR(D3DTSS_ALPHAARG2 );
D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT00 );
D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT01 );
D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT10 );
D3DSTATE_TO_STR(D3DTSS_BUMPENVMAT11 );
D3DSTATE_TO_STR(D3DTSS_TEXCOORDINDEX );
D3DSTATE_TO_STR(D3DTSS_ADDRESSU );
D3DSTATE_TO_STR(D3DTSS_ADDRESSV );
D3DSTATE_TO_STR(D3DTSS_BORDERCOLOR );
D3DSTATE_TO_STR(D3DTSS_MAGFILTER );
D3DSTATE_TO_STR(D3DTSS_MINFILTER );
D3DSTATE_TO_STR(D3DTSS_MIPFILTER );
D3DSTATE_TO_STR(D3DTSS_MIPMAPLODBIAS );
D3DSTATE_TO_STR(D3DTSS_MAXMIPLEVEL );
D3DSTATE_TO_STR(D3DTSS_MAXANISOTROPY );
D3DSTATE_TO_STR(D3DTSS_BUMPENVLSCALE );
D3DSTATE_TO_STR(D3DTSS_BUMPENVLOFFSET );
D3DSTATE_TO_STR(D3DTSS_TEXTURETRANSFORMFLAGS );
D3DSTATE_TO_STR(D3DTSS_ADDRESSW );
D3DSTATE_TO_STR(D3DTSS_COLORARG0 );
D3DSTATE_TO_STR(D3DTSS_ALPHAARG0 );
D3DSTATE_TO_STR(D3DTSS_RESULTARG );
D3DSTATE_TO_STR(WINED3DTSS_COLOROP );
D3DSTATE_TO_STR(WINED3DTSS_COLORARG1 );
D3DSTATE_TO_STR(WINED3DTSS_COLORARG2 );
D3DSTATE_TO_STR(WINED3DTSS_ALPHAOP );
D3DSTATE_TO_STR(WINED3DTSS_ALPHAARG1 );
D3DSTATE_TO_STR(WINED3DTSS_ALPHAARG2 );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVMAT00 );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVMAT01 );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVMAT10 );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVMAT11 );
D3DSTATE_TO_STR(WINED3DTSS_TEXCOORDINDEX );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLSCALE );
D3DSTATE_TO_STR(WINED3DTSS_BUMPENVLOFFSET );
D3DSTATE_TO_STR(WINED3DTSS_TEXTURETRANSFORMFLAGS );
D3DSTATE_TO_STR(WINED3DTSS_ADDRESSW );
D3DSTATE_TO_STR(WINED3DTSS_COLORARG0 );
D3DSTATE_TO_STR(WINED3DTSS_ALPHAARG0 );
D3DSTATE_TO_STR(WINED3DTSS_RESULTARG );
#undef D3DSTATE_TO_STR
case 12:
/* Note D3DTSS are not consecutive, so skip these */
......@@ -386,7 +397,7 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
scal_target = useext(GL_RGB_SCALE);
}
/* From MSDN (D3DTSS_ALPHAARG1) :
/* From MSDN (WINED3DTSS_ALPHAARG1) :
The default argument is D3DTA_TEXTURE. If no texture is set for this stage,
then the default argument is D3DTA_DIFFUSE.
FIXME? If texture added/removed, may need to reset back as well? */
......@@ -869,13 +880,13 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
DWORD d;
} tmpvalue;
tmpvalue.d = This->stateBlock->textureState[Stage][D3DTSS_BUMPENVMAT00];
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT00];
m[0][0] = tmpvalue.f;
tmpvalue.d = This->stateBlock->textureState[Stage][D3DTSS_BUMPENVMAT01];
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT01];
m[0][1] = tmpvalue.f;
tmpvalue.d = This->stateBlock->textureState[Stage][D3DTSS_BUMPENVMAT10];
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT10];
m[1][0] = tmpvalue.f;
tmpvalue.d = This->stateBlock->textureState[Stage][D3DTSS_BUMPENVMAT11];
tmpvalue.d = This->stateBlock->textureState[Stage][WINED3DTSS_BUMPENVMAT11];
m[1][1] = tmpvalue.f;
/*FIXME("Stage %d matrix is (%.2f,%.2f),(%.2f,%.2f)\n", Stage, m[0][0], m[0][1], m[1][0], m[1][0]);*/
......@@ -1393,9 +1404,9 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, D3DTEXTUREOP op,
DWORD op2;
if (isAlpha) {
op2 = This->stateBlock->textureState[Stage][D3DTSS_COLOROP];
op2 = This->stateBlock->textureState[Stage][WINED3DTSS_COLOROP];
} else {
op2 = This->stateBlock->textureState[Stage][D3DTSS_ALPHAOP];
op2 = This->stateBlock->textureState[Stage][WINED3DTSS_ALPHAOP];
}
/* Note: If COMBINE4 in effect can't go back to combine! */
......
......@@ -42,6 +42,9 @@
#include "wine/wined3d_interface.h"
#include "wine/wined3d_gl.h"
/* Device caps */
#define MAX_SAMPLERS 16
/* Swap chains */
#define MAX_SWAPCHAINS 256
......@@ -658,6 +661,7 @@ typedef struct SAVEDSTATES {
BOOL renderState[WINEHIGHEST_RENDER_STATE];
BOOL textureState[8][HIGHEST_TEXTURE_STATE];
BOOL clipplane[MAX_CLIPPLANES];
BOOL samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
BOOL vertexDecl;
BOOL pixelShader;
BOOL vertexShader;
......@@ -725,6 +729,9 @@ struct IWineD3DStateBlockImpl
/* Texture State Stage */
DWORD textureState[8][HIGHEST_TEXTURE_STATE];
/* Sampler States */
DWORD samplerState[MAX_SAMPLERS][HIGHEST_SAMPLER_STATE + 1];
};
extern const IWineD3DStateBlockVtbl IWineD3DStateBlock_Vtbl;
......
......@@ -883,6 +883,7 @@ typedef struct _WineD3D_GL_Info {
*/
UINT max_lights;
UINT max_textures;
UINT max_samplers;
UINT max_clipplanes;
GL_PSVersion ps_arb_version;
......
......@@ -348,8 +348,8 @@ DECLARE_INTERFACE_(IWineD3DDevice,IUnknown)
STDMETHOD(GetStreamSourceFreq)(THIS_ UINT StreamNumber, UINT* Divider) PURE;
STDMETHOD(SetTexture)(THIS_ DWORD Stage, IWineD3DBaseTexture* pTexture) PURE;
STDMETHOD(GetTexture)(THIS_ DWORD Stage, IWineD3DBaseTexture** ppTexture) PURE;
STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE;
STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD * pValue) PURE;
STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE;
STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage, WINED3DTEXTURESTAGESTATETYPE Type,DWORD *pValue) PURE;
STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX * pMatrix) PURE;
STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX * pMatrix) PURE;
STDMETHOD(SetVertexDeclaration)(THIS_ IWineD3DVertexDeclaration* pDecl) PURE;
......
......@@ -347,6 +347,30 @@ typedef enum _WINED3DSAMPLERSTATETYPE {
WINED3DSAMP_FORCE_DWORD = 0x7fffffff,
} WINED3DSAMPLERSTATETYPE;
typedef enum _WINED3DTEXTURESTAGESTATETYPE {
WINED3DTSS_COLOROP = 1,
WINED3DTSS_COLORARG1 = 2,
WINED3DTSS_COLORARG2 = 3,
WINED3DTSS_ALPHAOP = 4,
WINED3DTSS_ALPHAARG1 = 5,
WINED3DTSS_ALPHAARG2 = 6,
WINED3DTSS_BUMPENVMAT00 = 7,
WINED3DTSS_BUMPENVMAT01 = 8,
WINED3DTSS_BUMPENVMAT10 = 9,
WINED3DTSS_BUMPENVMAT11 = 10,
WINED3DTSS_TEXCOORDINDEX = 11,
WINED3DTSS_BUMPENVLSCALE = 22,
WINED3DTSS_BUMPENVLOFFSET = 23,
WINED3DTSS_TEXTURETRANSFORMFLAGS = 24,
WINED3DTSS_ADDRESSW = 25,
WINED3DTSS_COLORARG0 = 26,
WINED3DTSS_ALPHAARG0 = 27,
WINED3DTSS_RESULTARG = 28,
WINED3DTSS_CONSTANT = 32,
WINED3DTSS_FORCE_DWORD = 0x7fffffff
} WINED3DTEXTURESTAGESTATETYPE;
typedef struct _WINEDD3DRECTPATCH_INFO {
UINT StartVertexOffsetWidth;
UINT StartVertexOffsetHeight;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment