wined3d: Increase the sizes of texturing related arrays, in order to support vertex textures.
This commit is contained in:
parent
9c44b67d28
commit
5b7758f80c
|
@ -1810,7 +1810,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR
|
|||
/* TODO: Test if OpenGL is compiled in and loaded */
|
||||
|
||||
/* Initialize the texture unit mapping to a 1:1 mapping */
|
||||
for(state = 0; state < MAX_SAMPLERS; state++) {
|
||||
for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state) {
|
||||
if (state < GL_LIMITS(fragment_samplers)) {
|
||||
This->texUnitMap[state] = state;
|
||||
This->rev_tex_unit_map[state] = state;
|
||||
|
@ -1941,9 +1941,12 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Uninit3D(IWineD3DDevice *iface, D3DCB_D
|
|||
This->cursorTexture = 0;
|
||||
}
|
||||
|
||||
for (sampler = 0; sampler < MAX_SAMPLERS; ++sampler) {
|
||||
for (sampler = 0; sampler < MAX_FRAGMENT_SAMPLERS; ++sampler) {
|
||||
IWineD3DDevice_SetTexture(iface, sampler, NULL);
|
||||
}
|
||||
for (sampler = 0; sampler < MAX_VERTEX_SAMPLERS; ++sampler) {
|
||||
IWineD3DDevice_SetTexture(iface, WINED3DVERTEXTEXTURESAMPLER0 + sampler, NULL);
|
||||
}
|
||||
|
||||
/* Release the buffers (with sanity checks)*/
|
||||
TRACE("Releasing the depth stencil buffer at %p\n", This->stencilBufferTarget);
|
||||
|
@ -3215,7 +3218,7 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
|
|||
device_update_fixed_function_usage_map(This);
|
||||
|
||||
if (This->stateBlock->lowest_disabled_stage <= GL_LIMITS(textures)) {
|
||||
for (i = 0; i < MAX_SAMPLERS; ++i) {
|
||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
|
||||
if (This->texUnitMap[i] != i) {
|
||||
device_map_stage(This, i, i);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
|
||||
|
@ -3269,7 +3272,7 @@ static void device_map_fixed_function_samplers(IWineD3DDeviceImpl *This) {
|
|||
static void device_map_psamplers(IWineD3DDeviceImpl *This) {
|
||||
int i;
|
||||
|
||||
for (i = 0; i < MAX_SAMPLERS; ++i) {
|
||||
for (i = 0; i < MAX_FRAGMENT_SAMPLERS; ++i) {
|
||||
if (This->texUnitMap[i] != i) {
|
||||
device_map_stage(This, i, i);
|
||||
IWineD3DDeviceImpl_MarkStateDirty(This, STATE_SAMPLER(i));
|
||||
|
@ -6263,7 +6266,7 @@ static void WINAPI IWineD3DDeviceImpl_ResourceReleased(IWineD3DDevice *iface, IW
|
|||
case WINED3DRTYPE_TEXTURE:
|
||||
case WINED3DRTYPE_CUBETEXTURE:
|
||||
case WINED3DRTYPE_VOLUMETEXTURE:
|
||||
for (counter = 0; counter < MAX_SAMPLERS; counter++) {
|
||||
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++) {
|
||||
if (This->stateBlock != NULL && This->stateBlock->textures[counter] == (IWineD3DBaseTexture *)resource) {
|
||||
WARN("Texture being released is still by a stateblock, Stage = %u Texture = %p\n", counter, resource);
|
||||
This->stateBlock->textures[counter] = NULL;
|
||||
|
|
|
@ -570,7 +570,7 @@ BOOL IWineD3DImpl_FillGLCaps(WineD3D_GL_Info *gl_info, Display* display) {
|
|||
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_fragment_samplers = min(MAX_SAMPLERS, gl_max);
|
||||
gl_info->max_fragment_samplers = min(MAX_FRAGMENT_SAMPLERS, gl_max);
|
||||
GL_EXTCALL(glGetProgramivARB(GL_FRAGMENT_PROGRAM_ARB, GL_MAX_PROGRAM_ENV_PARAMETERS_ARB, &gl_max));
|
||||
TRACE_(d3d_caps)(" FOUND: ARB Pixel Shader support - max float constants=%u\n", gl_max);
|
||||
gl_info->ps_arb_constantsF = gl_max;
|
||||
|
|
|
@ -1124,7 +1124,7 @@ if(stridedlcl.u.s.type.VBO) { \
|
|||
{
|
||||
IWineD3DSurface *pSur;
|
||||
int textureNo;
|
||||
for (textureNo = 0; textureNo < MAX_SAMPLERS; ++textureNo) {
|
||||
for (textureNo = 0; textureNo < MAX_COMBINED_SAMPLERS; ++textureNo) {
|
||||
if (This->stateBlock->textures[textureNo] != NULL) {
|
||||
sprintf(buffer, "/tmp/texture_%p_%d_%d.tga", This->stateBlock->textures[textureNo], primCounter, textureNo);
|
||||
TRACE("Saving texture %s\n", buffer);
|
||||
|
|
|
@ -2247,7 +2247,7 @@ static void pixelshader(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3D
|
|||
* may be disabled because of WINED3DTSS_COLOROP = WINED3DTOP_DISABLE
|
||||
* make sure to enable them
|
||||
*/
|
||||
for(i=0; i < MAX_SAMPLERS; i++) {
|
||||
for(i=0; i < MAX_FRAGMENT_SAMPLERS; i++) {
|
||||
if(!isStateDirty(context, STATE_SAMPLER(i))) {
|
||||
sampler(STATE_SAMPLER(i), stateblock, context);
|
||||
}
|
||||
|
@ -3960,6 +3960,10 @@ const struct StateEntry StateTable[] =
|
|||
{ /*13, Sampler 13 */ STATE_SAMPLER(13), sampler },
|
||||
{ /*14, Sampler 14 */ STATE_SAMPLER(14), sampler },
|
||||
{ /*15, Sampler 15 */ STATE_SAMPLER(15), sampler },
|
||||
{ /*16, Vertex sampler 0 */ STATE_SAMPLER(16), sampler },
|
||||
{ /*17, Vertex sampler 1 */ STATE_SAMPLER(17), sampler },
|
||||
{ /*18, Vertex sampler 2 */ STATE_SAMPLER(18), sampler },
|
||||
{ /*19, Vertex sampler 3 */ STATE_SAMPLER(19), sampler },
|
||||
/* Pixel shader */
|
||||
{ /* , Pixel Shader */ STATE_PIXELSHADER, pixelshader },
|
||||
/* Transform states follow */
|
||||
|
|
|
@ -83,11 +83,11 @@ void stateblock_savedstates_copy(
|
|||
/* Fixed size arrays */
|
||||
memcpy(dest->streamSource, source->streamSource, bsize * MAX_STREAMS);
|
||||
memcpy(dest->streamFreq, source->streamFreq, bsize * MAX_STREAMS);
|
||||
memcpy(dest->textures, source->textures, bsize * MAX_SAMPLERS);
|
||||
memcpy(dest->textures, source->textures, bsize * MAX_COMBINED_SAMPLERS);
|
||||
memcpy(dest->transform, source->transform, bsize * (HIGHEST_TRANSFORMSTATE + 1));
|
||||
memcpy(dest->renderState, source->renderState, bsize * (WINEHIGHEST_RENDER_STATE + 1));
|
||||
memcpy(dest->textureState, source->textureState, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
|
||||
memcpy(dest->samplerState, source->samplerState, bsize * MAX_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_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);
|
||||
|
@ -121,11 +121,11 @@ void stateblock_savedstates_set(
|
|||
/* Fixed size arrays */
|
||||
memset(states->streamSource, value, bsize * MAX_STREAMS);
|
||||
memset(states->streamFreq, value, bsize * MAX_STREAMS);
|
||||
memset(states->textures, value, bsize * MAX_SAMPLERS);
|
||||
memset(states->textures, value, bsize * MAX_COMBINED_SAMPLERS);
|
||||
memset(states->transform, value, bsize * (HIGHEST_TRANSFORMSTATE + 1));
|
||||
memset(states->renderState, value, bsize * (WINEHIGHEST_RENDER_STATE + 1));
|
||||
memset(states->textureState, value, bsize * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
|
||||
memset(states->samplerState, value, bsize * MAX_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_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);
|
||||
|
@ -206,10 +206,10 @@ void stateblock_copy(
|
|||
memcpy(Dest->transforms, This->transforms, sizeof(WINED3DMATRIX) * (HIGHEST_TRANSFORMSTATE + 1));
|
||||
memcpy(Dest->clipplane, This->clipplane, sizeof(double) * MAX_CLIPPLANES * 4);
|
||||
memcpy(Dest->renderState, This->renderState, sizeof(DWORD) * (WINEHIGHEST_RENDER_STATE + 1));
|
||||
memcpy(Dest->textures, This->textures, sizeof(IWineD3DBaseTexture*) * MAX_SAMPLERS);
|
||||
memcpy(Dest->textureDimensions, This->textureDimensions, sizeof(int) * MAX_SAMPLERS);
|
||||
memcpy(Dest->textures, This->textures, sizeof(IWineD3DBaseTexture*) * MAX_COMBINED_SAMPLERS);
|
||||
memcpy(Dest->textureDimensions, This->textureDimensions, sizeof(int) * MAX_COMBINED_SAMPLERS);
|
||||
memcpy(Dest->textureState, This->textureState, sizeof(DWORD) * MAX_TEXTURES * (WINED3D_HIGHEST_TEXTURE_STATE + 1));
|
||||
memcpy(Dest->samplerState, This->samplerState, sizeof(DWORD) * MAX_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
|
||||
memcpy(Dest->samplerState, This->samplerState, sizeof(DWORD) * MAX_COMBINED_SAMPLERS * (WINED3D_HIGHEST_SAMPLER_STATE + 1));
|
||||
|
||||
/* Dynamically sized arrays */
|
||||
memcpy(Dest->vertexShaderConstantF, This->vertexShaderConstantF, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4);
|
||||
|
@ -257,7 +257,7 @@ static ULONG WINAPI IWineD3DStateBlockImpl_Release(IWineD3DStateBlock *iface) {
|
|||
FIXME("Releasing primary stateblock\n");
|
||||
|
||||
/* NOTE: according to MSDN: The application is responsible for making sure the texture references are cleared down */
|
||||
for (counter = 0; counter < MAX_SAMPLERS; counter++) {
|
||||
for (counter = 0; counter < MAX_COMBINED_SAMPLERS; counter++) {
|
||||
if (This->textures[counter]) {
|
||||
/* release our 'internal' hold on the texture */
|
||||
if(0 != IWineD3DBaseTexture_Release(This->textures[counter])) {
|
||||
|
@ -597,7 +597,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_Capture(IWineD3DStateBlock *iface)
|
|||
|
||||
/* Samplers */
|
||||
/* TODO: move over to using memcpy */
|
||||
for (j = 0; j < MAX_SAMPLERS; j++) {
|
||||
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||
if (This->set.textures[j]) {
|
||||
TRACE("Updating texture %d to %p (was %p)\n", j, targetStateBlock->textures[j], This->textures[j]);
|
||||
This->textures[j] = targetStateBlock->textures[j];
|
||||
|
@ -768,9 +768,13 @@ should really perform a delta so that only the changes get updated*/
|
|||
|
||||
/* Samplers */
|
||||
/* TODO: move over to memcpy */
|
||||
for (j = 0 ; j < MAX_SAMPLERS; j++){
|
||||
for (j = 0 ; j < MAX_COMBINED_SAMPLERS; j++){
|
||||
if (This->set.textures[j] && This->changed.textures[j]) {
|
||||
IWineD3DDevice_SetTexture(pDevice, j, This->textures[j]);
|
||||
if (j < MAX_FRAGMENT_SAMPLERS) {
|
||||
IWineD3DDevice_SetTexture(pDevice, j, This->textures[j]);
|
||||
} else {
|
||||
IWineD3DDevice_SetTexture(pDevice, WINED3DVERTEXTEXTURESAMPLER0 + j - MAX_FRAGMENT_SAMPLERS, This->textures[j]);
|
||||
}
|
||||
}
|
||||
for (i = 1; i <= WINED3D_HIGHEST_SAMPLER_STATE; i++){
|
||||
if (This->set.samplerState[j][i] && This->changed.samplerState[j][i]) {
|
||||
|
@ -798,7 +802,7 @@ should really perform a delta so that only the changes get updated*/
|
|||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_SAMPLERS; j++) {
|
||||
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||
for (i = 0; i < NUM_SAVEDPIXELSTATES_S; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][SavedPixelStates_S[i]] = This->samplerState[j][SavedPixelStates_S[i]];
|
||||
}
|
||||
|
@ -818,7 +822,7 @@ should really perform a delta so that only the changes get updated*/
|
|||
}
|
||||
}
|
||||
|
||||
for (j = 0; j < MAX_SAMPLERS; j++) {
|
||||
for (j = 0; j < MAX_COMBINED_SAMPLERS; j++) {
|
||||
for (i = 0; i < NUM_SAVEDVERTEXSTATES_S; i++) {
|
||||
((IWineD3DDeviceImpl *)pDevice)->stateBlock->samplerState[j][SavedVertexStates_S[i]] = This->samplerState[j][SavedVertexStates_S[i]];
|
||||
}
|
||||
|
@ -1040,7 +1044,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat
|
|||
This->lowest_disabled_stage = 1;
|
||||
|
||||
/* Sampler states*/
|
||||
for (i = 0 ; i < MAX_SAMPLERS; i++) {
|
||||
for (i = 0 ; i < MAX_COMBINED_SAMPLERS; i++) {
|
||||
TRACE("Setting up default samplers states for sampler %d\n", i);
|
||||
This->samplerState[i][WINED3DSAMP_ADDRESSU ] = WINED3DTADDRESS_WRAP;
|
||||
This->samplerState[i][WINED3DSAMP_ADDRESSV ] = WINED3DTADDRESS_WRAP;
|
||||
|
|
|
@ -74,13 +74,15 @@ void hash_table_put(hash_table_t *table, void *key, void *value);
|
|||
void hash_table_remove(hash_table_t *table, void *key);
|
||||
|
||||
/* Device caps */
|
||||
#define MAX_PALETTES 256
|
||||
#define MAX_STREAMS 16
|
||||
#define MAX_TEXTURES 8
|
||||
#define MAX_SAMPLERS 16
|
||||
#define MAX_ACTIVE_LIGHTS 8
|
||||
#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
|
||||
#define MAX_LEVELS 256
|
||||
#define MAX_PALETTES 256
|
||||
#define MAX_STREAMS 16
|
||||
#define MAX_TEXTURES 8
|
||||
#define MAX_FRAGMENT_SAMPLERS 16
|
||||
#define MAX_VERTEX_SAMPLERS 4
|
||||
#define MAX_COMBINED_SAMPLERS (MAX_FRAGMENT_SAMPLERS + MAX_VERTEX_SAMPLERS)
|
||||
#define MAX_ACTIVE_LIGHTS 8
|
||||
#define MAX_CLIPPLANES WINED3DMAXUSERCLIPPLANES
|
||||
#define MAX_LEVELS 256
|
||||
|
||||
#define MAX_CONST_I 16
|
||||
#define MAX_CONST_B 16
|
||||
|
@ -437,9 +439,9 @@ typedef void (*APPLYSTATEFUNC)(DWORD state, IWineD3DStateBlockImpl *stateblock,
|
|||
|
||||
/* + 1 because samplers start with 0 */
|
||||
#define STATE_SAMPLER(num) (STATE_TEXTURESTAGE(MAX_TEXTURES - 1, WINED3D_HIGHEST_TEXTURE_STATE) + 1 + (num))
|
||||
#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_SAMPLERS - 1))
|
||||
#define STATE_IS_SAMPLER(num) ((num) >= STATE_SAMPLER(0) && (num) <= STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1))
|
||||
|
||||
#define STATE_PIXELSHADER (STATE_SAMPLER(MAX_SAMPLERS - 1) + 1)
|
||||
#define STATE_PIXELSHADER (STATE_SAMPLER(MAX_COMBINED_SAMPLERS - 1) + 1)
|
||||
#define STATE_IS_PIXELSHADER(a) ((a) == STATE_PIXELSHADER)
|
||||
|
||||
#define STATE_TRANSFORM(a) (STATE_PIXELSHADER + (a))
|
||||
|
@ -722,8 +724,8 @@ struct IWineD3DDeviceImpl
|
|||
float posFixup[4];
|
||||
|
||||
/* With register combiners we can skip junk texture stages */
|
||||
DWORD texUnitMap[MAX_SAMPLERS];
|
||||
DWORD rev_tex_unit_map[MAX_SAMPLERS];
|
||||
DWORD texUnitMap[MAX_COMBINED_SAMPLERS];
|
||||
DWORD rev_tex_unit_map[MAX_COMBINED_SAMPLERS];
|
||||
BOOL fixed_function_usage_map[MAX_TEXTURES];
|
||||
BOOL oneToOneTexUnitMap;
|
||||
|
||||
|
@ -1212,12 +1214,12 @@ typedef struct SAVEDSTATES {
|
|||
BOOL fvf;
|
||||
BOOL streamSource[MAX_STREAMS];
|
||||
BOOL streamFreq[MAX_STREAMS];
|
||||
BOOL textures[MAX_SAMPLERS];
|
||||
BOOL textures[MAX_COMBINED_SAMPLERS];
|
||||
BOOL transform[HIGHEST_TRANSFORMSTATE + 1];
|
||||
BOOL viewport;
|
||||
BOOL renderState[WINEHIGHEST_RENDER_STATE + 1];
|
||||
BOOL textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
|
||||
BOOL samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
|
||||
BOOL samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
|
||||
BOOL clipplane[MAX_CLIPPLANES];
|
||||
BOOL vertexDecl;
|
||||
BOOL pixelShader;
|
||||
|
@ -1310,14 +1312,14 @@ struct IWineD3DStateBlockImpl
|
|||
DWORD renderState[WINEHIGHEST_RENDER_STATE + 1];
|
||||
|
||||
/* Texture */
|
||||
IWineD3DBaseTexture *textures[MAX_SAMPLERS];
|
||||
int textureDimensions[MAX_SAMPLERS];
|
||||
IWineD3DBaseTexture *textures[MAX_COMBINED_SAMPLERS];
|
||||
int textureDimensions[MAX_COMBINED_SAMPLERS];
|
||||
|
||||
/* Texture State Stage */
|
||||
DWORD textureState[MAX_TEXTURES][WINED3D_HIGHEST_TEXTURE_STATE + 1];
|
||||
DWORD lowest_disabled_stage;
|
||||
/* Sampler States */
|
||||
DWORD samplerState[MAX_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
|
||||
DWORD samplerState[MAX_COMBINED_SAMPLERS][WINED3D_HIGHEST_SAMPLER_STATE + 1];
|
||||
|
||||
/* Current GLSL Shader Program */
|
||||
struct glsl_shader_prog_link *glsl_program;
|
||||
|
@ -1560,7 +1562,7 @@ typedef struct shader_reg_maps {
|
|||
|
||||
/* Sampler usage tokens
|
||||
* Use 0 as default (bit 31 is always 1 on a valid token) */
|
||||
DWORD samplers[MAX_SAMPLERS];
|
||||
DWORD samplers[max(MAX_FRAGMENT_SAMPLERS, MAX_VERTEX_SAMPLERS)];
|
||||
char bumpmat;
|
||||
|
||||
/* Whether or not a loop is used in this shader */
|
||||
|
|
Loading…
Reference in New Issue