From 6be41fd59ac9e1ae6a0297ce780c5049ef1b5ddd Mon Sep 17 00:00:00 2001 From: Henri Verbeet Date: Thu, 22 Oct 2009 10:09:54 +0200 Subject: [PATCH] wined3d: Get rid of GL_LIMITS. --- dlls/wined3d/arb_program_shader.c | 42 +++++----- dlls/wined3d/ati_fragment_shader.c | 12 ++- dlls/wined3d/context.c | 52 +++++++------ dlls/wined3d/device.c | 45 +++++++---- dlls/wined3d/directx.c | 23 +++--- dlls/wined3d/drawprim.c | 10 ++- dlls/wined3d/glsl_shader.c | 56 ++++++++------ dlls/wined3d/nvidia_texture_shader.c | 16 ++-- dlls/wined3d/state.c | 110 +++++++++++++++++---------- dlls/wined3d/stateblock.c | 26 ++++--- dlls/wined3d/surface.c | 5 +- dlls/wined3d/utils.c | 33 ++++---- dlls/wined3d/vertexshader.c | 17 +++-- dlls/wined3d/wined3d_private.h | 1 - 14 files changed, 266 insertions(+), 182 deletions(-) diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 38d3fd25917..565f2ef91e6 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -633,12 +633,15 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s * account for the helper const too because we have to declare all availabke d3d constants * and don't know which are actually used. */ - if(pshader) { - max_constantsF = GL_LIMITS(ps_arb_constantsF); - } else { + if (pshader) + { + max_constantsF = gl_info->max_ps_arb_constantsF; + } + else + { if(This->baseShader.reg_maps.usesrelconstF) { DWORD highest_constf = 0, clip_limit; - max_constantsF = GL_LIMITS(vs_arb_constantsF) - reserved_vs_const(iface, gl_info); + max_constantsF = gl_info->max_vs_arb_constantsF - reserved_vs_const(iface, gl_info); max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants); for(i = 0; i < This->baseShader.limits.constant_float; i++) @@ -650,7 +653,7 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s if(use_nv_clip(gl_info) && ctx->target_version >= NV2) { - clip_limit = GL_LIMITS(clipplanes); + clip_limit = gl_info->max_clipplanes; } else { @@ -661,14 +664,14 @@ static DWORD shader_generate_arb_declarations(IWineD3DBaseShader *iface, const s max_constantsF -= *num_clipplanes; if(*num_clipplanes < clip_limit) { - WARN("Only %u clipplanes out of %u enabled\n", *num_clipplanes, GL_LIMITS(clipplanes)); + WARN("Only %u clipplanes out of %u enabled\n", *num_clipplanes, gl_info->max_clipplanes); } } else { - if(ctx->target_version >= NV2) *num_clipplanes = GL_LIMITS(clipplanes); - else *num_clipplanes = min(GL_LIMITS(clipplanes), 4); - max_constantsF = GL_LIMITS(vs_arb_constantsF); + if (ctx->target_version >= NV2) *num_clipplanes = gl_info->max_clipplanes; + else *num_clipplanes = min(gl_info->max_clipplanes, 4); + max_constantsF = gl_info->max_vs_arb_constantsF; } } @@ -2939,7 +2942,7 @@ static void vshader_add_footer(IWineD3DVertexShaderImpl *This, struct wined3d_sh unsigned int cur_clip = 0; char component[4] = {'x', 'y', 'z', 'w'}; - for(i = 0; i < GL_LIMITS(clipplanes); i++) + for (i = 0; i < gl_info->max_clipplanes; ++i) { if(args->boolclip.clipplane_mask & (1 << i)) { @@ -3481,7 +3484,7 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct struct arb_ps_np2fixup_info* const fixup = priv_ctx.cur_np2fixup_info; const WORD map = priv_ctx.cur_ps_args->super.np2_fixup; - const UINT max_lconsts = GL_LIMITS(ps_arb_local_constants); + const UINT max_lconsts = gl_info->max_ps_arb_local_constants; fixup->offset = next_local; fixup->super.active = 0; @@ -3998,7 +4001,7 @@ static struct arb_ps_compiled_shader *find_arb_pshader(IWineD3DPixelShaderImpl * if (!device->vs_clipping) shader_data->clipplane_emulation = shader_find_free_input_register(&shader->baseShader.reg_maps, - GL_LIMITS(texture_stages) - 1); + gl_info->max_texture_stages - 1); else shader_data->clipplane_emulation = ~0U; } @@ -4207,7 +4210,7 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW args->ps_signature = ~0; if(!dev->vs_clipping) { - args->boolclip.clip_texcoord = ffp_clip_emul(stateblock) ? GL_LIMITS(texture_stages) : 0; + args->boolclip.clip_texcoord = ffp_clip_emul(stateblock) ? gl_info->max_texture_stages : 0; } /* Otherwise: Setting boolclip_compare set clip_texcoord to 0 */ } @@ -4527,7 +4530,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0); TRACE_(d3d_caps)("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n"); } - else if(GL_LIMITS(vs_arb_constantsF) >= 256) + else if (gl_info->max_vs_arb_constantsF >= 256) { /* Shader Model 2.0 requires at least 256 vertex shader constants */ pCaps->VertexShaderVersion = WINED3DVS_VERSION(2,0); @@ -4538,7 +4541,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ pCaps->VertexShaderVersion = WINED3DVS_VERSION(1,1); TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled (ARB_PROGRAM)\n"); } - pCaps->MaxVertexShaderConst = GL_LIMITS(vs_arb_constantsF); + pCaps->MaxVertexShaderConst = gl_info->max_vs_arb_constantsF; } if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { @@ -4547,7 +4550,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0); TRACE_(d3d_caps)("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n"); } - else if(GL_LIMITS(ps_arb_constantsF) >= 32) + else if (gl_info->max_ps_arb_constantsF >= 32) { /* Shader Model 2.0 requires at least 32 pixel shader constants */ pCaps->PixelShaderVersion = WINED3DPS_VERSION(2,0); @@ -4559,7 +4562,7 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled (ARB_PROGRAM)\n"); } pCaps->PixelShader1xMaxValue = 8.0f; - pCaps->MaxPixelShaderConst = GL_LIMITS(ps_arb_constantsF); + pCaps->MaxPixelShaderConst = gl_info->max_ps_arb_constantsF; } pCaps->VSClipping = use_nv_clip(gl_info); @@ -5203,7 +5206,7 @@ static void arbfp_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_info /* TODO: Implement WINED3DTEXOPCAPS_PREMODULATE */ caps->MaxTextureBlendStages = 8; - caps->MaxSimultaneousTextures = min(GL_LIMITS(fragment_samplers), 8); + caps->MaxSimultaneousTextures = min(gl_info->max_fragment_samplers, 8); caps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_TSSARGTEMP; } @@ -5857,7 +5860,8 @@ static void fragment_prog_arbfp(DWORD state, IWineD3DStateBlockImpl *stateblock, return; } new_desc->num_textures_used = 0; - for(i = 0; i < GL_LIMITS(texture_stages); i++) { + for (i = 0; i < context->gl_info->max_texture_stages; ++i) + { if(settings.op[i].cop == WINED3DTOP_DISABLE) break; new_desc->num_textures_used = i; } diff --git a/dlls/wined3d/ati_fragment_shader.c b/dlls/wined3d/ati_fragment_shader.c index bba85f61b74..50d288f162e 100644 --- a/dlls/wined3d/ati_fragment_shader.c +++ b/dlls/wined3d/ati_fragment_shader.c @@ -402,7 +402,8 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con checkGLcall("GL_EXTCALL(glBeginFragmentShaderATI())"); /* Pass 1: Generate sampling instructions for perturbation maps */ - for(stage = 0; stage < GL_LIMITS(textures); stage++) { + for (stage = 0; stage < gl_info->max_textures; ++stage) + { if(op[stage].cop == WINED3DTOP_DISABLE) break; if(op[stage].cop != WINED3DTOP_BUMPENVMAP && op[stage].cop != WINED3DTOP_BUMPENVMAPLUMINANCE) continue; @@ -427,7 +428,8 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con } /* Pass 2: Generate perturbation calculations */ - for(stage = 0; stage < GL_LIMITS(textures); stage++) { + for (stage = 0; stage < gl_info->max_textures; ++stage) + { GLuint argmodextra_x, argmodextra_y; struct color_fixup_desc fixup; @@ -475,7 +477,8 @@ static GLuint gen_ati_shader(const struct texture_stage_op op[MAX_TEXTURES], con } /* Pass 3: Generate sampling instructions for regular textures */ - for(stage = 0; stage < GL_LIMITS(textures); stage++) { + for (stage = 0; stage < gl_info->max_textures; ++stage) + { if(op[stage].cop == WINED3DTOP_DISABLE) { break; } @@ -815,7 +818,8 @@ static void set_tex_op_atifs(DWORD state, IWineD3DStateBlockImpl *stateblock, st return; } new_desc->num_textures_used = 0; - for(i = 0; i < GL_LIMITS(texture_stages); i++) { + for (i = 0; i < context->gl_info->max_texture_stages; ++i) + { if(settings.op[i].cop == WINED3DTOP_DISABLE) break; new_desc->num_textures_used = i; } diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 53997c8fbef..66ba35849e0 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -88,7 +88,7 @@ static void context_clean_fbo_attachments(const struct wined3d_gl_info *gl_info) { unsigned int i; - for (i = 0; i < GL_LIMITS(buffers); ++i) + for (i = 0; i < gl_info->max_buffers; ++i) { gl_info->fbo_ops.glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0 + i, GL_TEXTURE_2D, 0, 0); checkGLcall("glFramebufferTexture2D()"); @@ -289,7 +289,7 @@ static void context_check_fbo_status(struct wined3d_context *context) FIXME("FBO status %s (%#x)\n", debug_fbostatus(status), status); /* Dump the FBO attachments */ - for (i = 0; i < GL_LIMITS(buffers); ++i) + for (i = 0; i < gl_info->max_buffers; ++i) { attachment = (IWineD3DSurfaceImpl *)context->current_fbo->render_targets[i]; if (attachment) @@ -316,8 +316,8 @@ static struct fbo_entry *context_create_fbo_entry(struct wined3d_context *contex struct fbo_entry *entry; entry = HeapAlloc(GetProcessHeap(), 0, sizeof(*entry)); - entry->render_targets = HeapAlloc(GetProcessHeap(), 0, GL_LIMITS(buffers) * sizeof(*entry->render_targets)); - memcpy(entry->render_targets, device->render_targets, GL_LIMITS(buffers) * sizeof(*entry->render_targets)); + entry->render_targets = HeapAlloc(GetProcessHeap(), 0, gl_info->max_buffers * sizeof(*entry->render_targets)); + memcpy(entry->render_targets, device->render_targets, gl_info->max_buffers * sizeof(*entry->render_targets)); entry->depth_stencil = device->stencilBufferTarget; entry->attached = FALSE; entry->id = 0; @@ -334,7 +334,7 @@ static void context_reuse_fbo_entry(struct wined3d_context *context, struct fbo_ context_bind_fbo(context, GL_FRAMEBUFFER, &entry->id); context_clean_fbo_attachments(gl_info); - memcpy(entry->render_targets, device->render_targets, GL_LIMITS(buffers) * sizeof(*entry->render_targets)); + memcpy(entry->render_targets, device->render_targets, gl_info->max_buffers * sizeof(*entry->render_targets)); entry->depth_stencil = device->stencilBufferTarget; entry->attached = FALSE; } @@ -363,7 +363,8 @@ static struct fbo_entry *context_find_fbo_entry(struct wined3d_context *context) LIST_FOR_EACH_ENTRY(entry, &context->fbo_list, struct fbo_entry, entry) { - if (!memcmp(entry->render_targets, device->render_targets, GL_LIMITS(buffers) * sizeof(*entry->render_targets)) + if (!memcmp(entry->render_targets, + device->render_targets, gl_info->max_buffers * sizeof(*entry->render_targets)) && entry->depth_stencil == device->stencilBufferTarget) { list_remove(&entry->entry); @@ -401,7 +402,7 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_ if (!entry->attached) { /* Apply render targets */ - for (i = 0; i < GL_LIMITS(buffers); ++i) + for (i = 0; i < gl_info->max_buffers; ++i) { IWineD3DSurface *render_target = device->render_targets[i]; context_attach_surface_fbo(context, GL_FRAMEBUFFER, i, render_target); @@ -418,8 +419,10 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_ context_attach_depth_stencil_fbo(context, GL_FRAMEBUFFER, device->stencilBufferTarget, TRUE); entry->attached = TRUE; - } else { - for (i = 0; i < GL_LIMITS(buffers); ++i) + } + else + { + for (i = 0; i < gl_info->max_buffers; ++i) { if (device->render_targets[i]) context_apply_attachment_filter_states(device->render_targets[i], FALSE); @@ -428,7 +431,7 @@ static void context_apply_fbo_entry(struct wined3d_context *context, struct fbo_ context_apply_attachment_filter_states(device->stencilBufferTarget, FALSE); } - for (i = 0; i < GL_LIMITS(buffers); ++i) + for (i = 0; i < gl_info->max_buffers; ++i) { if (device->render_targets[i]) device->draw_buffers[i] = GL_COLOR_ATTACHMENT0 + i; @@ -612,7 +615,7 @@ void context_resource_released(IWineD3DDevice *iface, IWineD3DResource *resource continue; } - for (j = 0; j < GL_LIMITS(buffers); ++j) + for (j = 0; j < gl_info->max_buffers; ++j) { if (entry->render_targets[j] == (IWineD3DSurface *)resource) { @@ -1277,13 +1280,13 @@ struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceI if(This->shader_backend->shader_dirtifyable_constants((IWineD3DDevice *) This)) { /* Create the dirty constants array and initialize them to dirty */ ret->vshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, - sizeof(*ret->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); + sizeof(*ret->vshader_const_dirty) * gl_info->max_vshader_constantsF); ret->pshader_const_dirty = HeapAlloc(GetProcessHeap(), 0, - sizeof(*ret->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); + sizeof(*ret->pshader_const_dirty) * gl_info->max_pshader_constantsF); memset(ret->vshader_const_dirty, 1, - sizeof(*ret->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); + sizeof(*ret->vshader_const_dirty) * gl_info->max_vshader_constantsF); memset(ret->pshader_const_dirty, 1, - sizeof(*ret->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); + sizeof(*ret->pshader_const_dirty) * gl_info->max_pshader_constantsF); } ret->free_occlusion_query_size = 4; @@ -1359,7 +1362,8 @@ struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceI /* Set up the previous texture input for all shader units. This applies to bump mapping, and in d3d * the previous texture where to source the offset from is always unit - 1. */ - for(s = 1; s < GL_LIMITS(textures); s++) { + for (s = 1; s < gl_info->max_textures; ++s) + { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s)); glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, GL_TEXTURE0_ARB + s - 1); checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ..."); @@ -1384,7 +1388,8 @@ struct wined3d_context *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceI GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, strlen(dummy_program), dummy_program)); } - for(s = 0; s < GL_LIMITS(point_sprite_units); s++) { + for (s = 0; s < gl_info->max_point_sprite_units; ++s) + { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + s)); glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE); checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)"); @@ -1594,7 +1599,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context * The blitting code uses (for now) the fixed function pipeline, so make sure to reset all fixed * function texture unit. No need to care for higher samplers */ - for(i = GL_LIMITS(textures) - 1; i > 0 ; i--) { + for (i = gl_info->max_textures - 1; i > 0 ; --i) + { sampler = This->rev_tex_unit_map[i]; GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i)); checkGLcall("glActiveTextureARB"); @@ -1986,7 +1992,7 @@ static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit { if (GL_SUPPORT(ARB_DRAW_BUFFERS)) { - GL_EXTCALL(glDrawBuffersARB(GL_LIMITS(buffers), device->draw_buffers)); + GL_EXTCALL(glDrawBuffersARB(gl_info->max_buffers, device->draw_buffers)); checkGLcall("glDrawBuffers()"); } else @@ -2047,14 +2053,14 @@ struct wined3d_context *ActivateContext(IWineD3DDeviceImpl *This, IWineD3DSurfac if (context->vshader_const_dirty) { memset(context->vshader_const_dirty, 1, - sizeof(*context->vshader_const_dirty) * GL_LIMITS(vshader_constantsF)); - This->highest_dirty_vs_const = GL_LIMITS(vshader_constantsF); + sizeof(*context->vshader_const_dirty) * gl_info->max_vshader_constantsF); + This->highest_dirty_vs_const = gl_info->max_vshader_constantsF; } if (context->pshader_const_dirty) { memset(context->pshader_const_dirty, 1, - sizeof(*context->pshader_const_dirty) * GL_LIMITS(pshader_constantsF)); - This->highest_dirty_ps_const = GL_LIMITS(pshader_constantsF); + sizeof(*context->pshader_const_dirty) * gl_info->max_pshader_constantsF); + This->highest_dirty_ps_const = gl_info->max_pshader_constantsF; } } diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 2d0004ec9d1..ec569800123 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -1690,7 +1690,9 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This) { glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)"); } - for (i = 0; i < GL_LIMITS(textures); i++) { + + for (i = 0; i < This->adapter->gl_info.max_textures; ++i) + { GLubyte white = 255; /* Make appropriate texture active */ @@ -1723,6 +1725,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPRESENT_PARAMETERS *pPresentationParameters) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; IWineD3DSwapChainImpl *swapchain = NULL; HRESULT hr; DWORD state; @@ -1749,8 +1752,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, This->updateStateBlock = This->stateBlock; IWineD3DStateBlock_AddRef((IWineD3DStateBlock*)This->updateStateBlock); - This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DSurface *) * GL_LIMITS(buffers)); - This->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(GLenum) * GL_LIMITS(buffers)); + This->render_targets = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(IWineD3DSurface *) * gl_info->max_buffers); + This->draw_buffers = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(GLenum) * gl_info->max_buffers); This->NumberOfPalettes = 1; This->palettes = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(PALETTEENTRY*)); @@ -1772,8 +1777,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, This->currentPalette = 0; /* Initialize the texture unit mapping to a 1:1 mapping */ - for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state) { - if (state < GL_LIMITS(fragment_samplers)) { + for (state = 0; state < MAX_COMBINED_SAMPLERS; ++state) + { + if (state < gl_info->max_fragment_samplers) + { This->texUnitMap[state] = state; This->rev_tex_unit_map[state] = state; } else { @@ -2716,7 +2723,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetClipPlane(IWineD3DDevice *iface, DWO TRACE("(%p) : for idx %d, %p\n", This, Index, pPlane); /* Validate Index */ - if (Index >= GL_LIMITS(clipplanes)) { + if (Index >= This->adapter->gl_info.max_clipplanes) + { TRACE("Application has requested clipplane this device doesn't support\n"); return WINED3DERR_INVALIDCALL; } @@ -2752,7 +2760,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_GetClipPlane(IWineD3DDevice *iface, DWO TRACE("(%p) : for idx %d\n", This, Index); /* Validate Index */ - if (Index >= GL_LIMITS(clipplanes)) { + if (Index >= This->adapter->gl_info.max_clipplanes) + { TRACE("Application has requested clipplane this device doesn't support\n"); return WINED3DERR_INVALIDCALL; } @@ -3451,7 +3460,7 @@ static void device_map_vsamplers(IWineD3DDeviceImpl *This, BOOL ps) { const WINED3DSAMPLER_TEXTURE_TYPE *vshader_sampler_type = ((IWineD3DVertexShaderImpl *)This->stateBlock->vertexShader)->baseShader.reg_maps.sampler_type; const WINED3DSAMPLER_TEXTURE_TYPE *pshader_sampler_type = NULL; - int start = min(MAX_COMBINED_SAMPLERS, GL_LIMITS(combined_samplers)) - 1; + int start = min(MAX_COMBINED_SAMPLERS, This->adapter->gl_info.max_combined_samplers) - 1; int i; if (ps) { @@ -4165,7 +4174,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetTextureStageState(IWineD3DDevice *if * Again stage Stage doesn't need to be dirtified here, it is handled below. */ - for(i = Stage + 1; i < GL_LIMITS(texture_stages); i++) { + for (i = Stage + 1; i < This->adapter->gl_info.max_texture_stages; ++i) + { if(This->updateStateBlock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) { break; } @@ -5865,8 +5875,10 @@ static void WINAPI IWineD3DDeviceImpl_ClearRendertargetView(IWineD3DDevice *ifac static HRESULT WINAPI IWineD3DDeviceImpl_GetRenderTarget(IWineD3DDevice* iface,DWORD RenderTargetIndex, IWineD3DSurface **ppRenderTarget) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; - if (RenderTargetIndex >= GL_LIMITS(buffers)) { - ERR("(%p) : Only %d render targets are supported.\n", This, GL_LIMITS(buffers)); + if (RenderTargetIndex >= This->adapter->gl_info.max_buffers) + { + ERR("(%p) : Only %d render targets are supported.\n", + This, This->adapter->gl_info.max_buffers); return WINED3DERR_INVALIDCALL; } @@ -6134,9 +6146,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface, TRACE("(%p) : Setting rendertarget %d to %p\n", This, RenderTargetIndex, pRenderTarget); - if (RenderTargetIndex >= GL_LIMITS(buffers)) { + if (RenderTargetIndex >= This->adapter->gl_info.max_buffers) + { WARN("(%p) : Unsupported target %u set, returning WINED3DERR_INVALIDCALL(only %u supported)\n", - This, RenderTargetIndex, GL_LIMITS(buffers)); + This, RenderTargetIndex, This->adapter->gl_info.max_buffers); return WINED3DERR_INVALIDCALL; } @@ -6598,7 +6611,8 @@ void delete_opengl_contexts(IWineD3DDevice *iface, IWineD3DSwapChain *swapchain_ This->shader_backend->shader_free_private(iface); ENTER_GL(); - for (i = 0; i < GL_LIMITS(textures); i++) { + for (i = 0; i < This->adapter->gl_info.max_textures; ++i) + { /* Textures are recreated below */ glDeleteTextures(1, &This->dummyTextureName[i]); checkGLcall("glDeleteTextures(1, &This->dummyTextureName[i])"); @@ -6929,7 +6943,8 @@ void device_resource_released(IWineD3DDeviceImpl *This, IWineD3DResource *resour if (This->d3d_initialized) { - for (i = 0; i < GL_LIMITS(buffers); ++i) { + for (i = 0; i < This->adapter->gl_info.max_buffers; ++i) + { if (This->render_targets[i] == (IWineD3DSurface *)resource) { This->render_targets[i] = NULL; } diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index bc9691f6811..2259a867ce2 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -3183,7 +3183,8 @@ static BOOL CheckVertexTextureCapability(struct wined3d_adapter *adapter, const { const struct wined3d_gl_info *gl_info = &adapter->gl_info; - if (!GL_LIMITS(vertex_samplers)) { + if (!gl_info->max_vertex_samplers) + { TRACE_(d3d_caps)("[FAILED]\n"); return FALSE; } @@ -4067,16 +4068,16 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, * idea how generating the smoothing alpha values works; the result is different */ - pCaps->MaxTextureWidth = GL_LIMITS(texture_size); - pCaps->MaxTextureHeight = GL_LIMITS(texture_size); + pCaps->MaxTextureWidth = gl_info->max_texture_size; + pCaps->MaxTextureHeight = gl_info->max_texture_size; if(GL_SUPPORT(EXT_TEXTURE3D)) - pCaps->MaxVolumeExtent = GL_LIMITS(texture3d_size); + pCaps->MaxVolumeExtent = gl_info->max_texture3d_size; else pCaps->MaxVolumeExtent = 0; pCaps->MaxTextureRepeat = 32768; - pCaps->MaxTextureAspectRatio = GL_LIMITS(texture_size); + pCaps->MaxTextureAspectRatio = gl_info->max_texture_size; pCaps->MaxVertexW = 1.0f; pCaps->GuardBandLeft = 0.0f; @@ -4102,14 +4103,14 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->FVFCaps = WINED3DFVFCAPS_PSIZE | 0x0008; /* 8 texture coords */ - pCaps->MaxUserClipPlanes = GL_LIMITS(clipplanes); - pCaps->MaxActiveLights = GL_LIMITS(lights); + pCaps->MaxUserClipPlanes = gl_info->max_clipplanes; + pCaps->MaxActiveLights = gl_info->max_lights; - pCaps->MaxVertexBlendMatrices = GL_LIMITS(blends); + pCaps->MaxVertexBlendMatrices = gl_info->max_blends; pCaps->MaxVertexBlendMatrixIndex = 0; - pCaps->MaxAnisotropy = GL_LIMITS(anisotropy); - pCaps->MaxPointSize = GL_LIMITS(pointsize); + pCaps->MaxAnisotropy = gl_info->max_anisotropy; + pCaps->MaxPointSize = gl_info->max_pointsize; /* FIXME: Add D3DVTXPCAPS_TWEENING, D3DVTXPCAPS_TEXGEN_SPHEREMAP */ @@ -4133,7 +4134,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->AdapterOrdinalInGroup = 0; pCaps->NumberOfAdaptersInGroup = 1; - pCaps->NumSimultaneousRTs = GL_LIMITS(buffers); + pCaps->NumSimultaneousRTs = gl_info->max_buffers; pCaps->StretchRectFilterCaps = WINED3DPTFILTERCAPS_MINFPOINT | WINED3DPTFILTERCAPS_MAGFPOINT | diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index e2e907fcd04..acf89be1885 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -76,7 +76,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context long SkipnStrides = startIdx + This->stateBlock->loadBaseVertexIndex; BOOL pixelShader = use_ps(This->stateBlock); BOOL specular_fog = FALSE; - UINT texture_stages = GL_LIMITS(texture_stages); + UINT texture_stages = context->gl_info->max_texture_stages; const BYTE *texCoords[WINED3DDP_MAXTEXCOORD]; const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL; const struct wined3d_stream_info_element *element; @@ -582,7 +582,7 @@ void drawPrimitive(IWineD3DDevice *iface, UINT index_count, UINT StartIdx, UINT if (This->stateBlock->renderState[WINED3DRS_COLORWRITEENABLE]) { /* Invalidate the back buffer memory so LockRect will read it the next time */ - for (i = 0; i < GL_LIMITS(buffers); ++i) + for (i = 0; i < This->adapter->gl_info.max_buffers; ++i) { target = (IWineD3DSurfaceImpl *)This->render_targets[i]; if (target) @@ -766,6 +766,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, float max_x = 0.0f, max_y = 0.0f, max_z = 0.0f, neg_z = 0.0f; struct wined3d_stream_info stream_info; struct wined3d_stream_info_element *e; + const struct wined3d_context *context; const BYTE *data; const WINED3DRECTPATCH_INFO *info = &patch->RectPatchInfo; DWORD vtxStride; @@ -775,7 +776,7 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, /* Simply activate the context for blitting. This disables all the things we don't want and * takes care of dirtifying. Dirtifying is preferred over pushing / popping, since drawing the * patch (as opposed to normal draws) will most likely need different changes anyway. */ - ActivateContext(This, NULL, CTXUSAGE_BLIT); + context = ActivateContext(This, NULL, CTXUSAGE_BLIT); /* First, locate the position data. This is provided in a vertex buffer in the stateblock. * Beware of vbos @@ -857,7 +858,8 @@ HRESULT tesselate_rectpatch(IWineD3DDeviceImpl *This, checkGLcall("glLightModel for MODEL_AMBIENT"); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_RENDER(WINED3DRS_AMBIENT)); - for(i = 3; i < GL_LIMITS(lights); i++) { + for (i = 3; i < context->gl_info->max_lights; ++i) + { glDisable(GL_LIGHT0 + i); checkGLcall("glDisable(GL_LIGHT0 + i)"); IWineD3DDeviceImpl_MarkStateDirty(This, STATE_ACTIVELIGHT(i)); diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index 6a074b196d2..74439f43d2b 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -254,7 +254,7 @@ static void shader_glsl_load_psamplers(const struct wined3d_gl_info *gl_info, name_loc = GL_EXTCALL(glGetUniformLocationARB(programId, sampler_name)); if (name_loc != -1) { DWORD mapped_unit = tex_unit_map[i]; - if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(fragment_samplers)) + if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < gl_info->max_fragment_samplers) { TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit); GL_EXTCALL(glUniform1iARB(name_loc, mapped_unit)); @@ -279,7 +279,7 @@ static void shader_glsl_load_vsamplers(const struct wined3d_gl_info *gl_info, name_loc = GL_EXTCALL(glGetUniformLocationARB(programId, sampler_name)); if (name_loc != -1) { DWORD mapped_unit = tex_unit_map[MAX_FRAGMENT_SAMPLERS + i]; - if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < GL_LIMITS(combined_samplers)) + if (mapped_unit != WINED3D_UNMAPPED_STAGE && mapped_unit < gl_info->max_combined_samplers) { TRACE("Loading %s for texture %d\n", sampler_name, mapped_unit); GL_EXTCALL(glUniform1iARB(name_loc, mapped_unit)); @@ -794,7 +794,7 @@ static void shader_glsl_update_float_pixel_constants(IWineD3DDevice *iface, UINT static unsigned int vec4_varyings(DWORD shader_major, const struct wined3d_gl_info *gl_info) { - unsigned int ret = GL_LIMITS(glsl_varyings) / 4; + unsigned int ret = gl_info->max_glsl_varyings / 4; /* 4.0 shaders do not write clip coords because d3d10 does not support user clipplanes */ if(shader_major > 3) return ret; @@ -844,8 +844,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont */ if(pshader) { /* No indirect addressing here */ - max_constantsF = GL_LIMITS(ps_glsl_constantsF); - } else { + max_constantsF = gl_info->max_ps_glsl_constantsF; + } + else + { if(This->baseShader.reg_maps.usesrelconstF) { /* Subtract the other potential uniforms from the max available (bools, ints, and 1 row of projection matrix). * Subtract another uniform for immediate values, which have to be loaded via uniform by the driver as well. @@ -854,7 +856,7 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont * * Writing gl_ClipPos requires one uniform for each clipplane as well. */ - max_constantsF = GL_LIMITS(vs_glsl_constantsF) - 3 - GL_LIMITS(clipplanes); + max_constantsF = gl_info->max_vs_glsl_constantsF - 3 - gl_info->max_clipplanes; max_constantsF -= count_bits(This->baseShader.reg_maps.integer_constants); /* Strictly speaking a bool only uses one scalar, but the nvidia(Linux) compiler doesn't pack them properly, * so each scalar requires a full vec4. We could work around this by packing the booleans ourselves, but @@ -863,8 +865,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont max_constantsF -= count_bits(This->baseShader.reg_maps.boolean_constants); /* Set by driver quirks in directx.c */ max_constantsF -= gl_info->reserved_glsl_constants; - } else { - max_constantsF = GL_LIMITS(vs_glsl_constantsF); + } + else + { + max_constantsF = gl_info->max_vs_glsl_constantsF; } } max_constantsF = min(This->baseShader.limits.constant_float, max_constantsF); @@ -922,8 +926,10 @@ static void shader_generate_glsl_declarations(const struct wined3d_context *cont shader_addline(buffer, "const vec4 srgb_const1 = vec4(%.8e, 0.0, 0.0, 0.0);\n", srgb_cmp); } - if(reg_maps->vpos || reg_maps->usesdsy) { - if(This->baseShader.limits.constant_float + extra_constants_needed + 1 < GL_LIMITS(ps_glsl_constantsF)) { + if (reg_maps->vpos || reg_maps->usesdsy) + { + if (This->baseShader.limits.constant_float + extra_constants_needed + 1 < gl_info->max_ps_glsl_constantsF) + { shader_addline(buffer, "uniform vec4 ycorrection;\n"); ((IWineD3DPixelShaderImpl *) This)->vpos_uniform = 1; extra_constants_needed++; @@ -1308,8 +1314,8 @@ static void shader_glsl_get_register_name(const struct wined3d_shader_register * break; case WINED3DSPR_COLOROUT: - if (reg->idx >= GL_LIMITS(buffers)) - WARN("Write to render target %u, only %d supported\n", reg->idx, GL_LIMITS(buffers)); + if (reg->idx >= gl_info->max_buffers) + WARN("Write to render target %u, only %d supported\n", reg->idx, gl_info->max_buffers); sprintf(register_name, "gl_FragData[%u]", reg->idx); break; @@ -4132,21 +4138,25 @@ static void set_glsl_shader_program(const struct wined3d_context *context, GL_EXTCALL(glLinkProgramARB(programId)); print_glsl_info_log(gl_info, programId); - entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(vs_glsl_constantsF)); - for (i = 0; i < GL_LIMITS(vs_glsl_constantsF); ++i) { + entry->vuniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * gl_info->max_vs_glsl_constantsF); + for (i = 0; i < gl_info->max_vs_glsl_constantsF; ++i) + { snprintf(glsl_name, sizeof(glsl_name), "VC[%i]", i); entry->vuniformF_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name)); } - for (i = 0; i < MAX_CONST_I; ++i) { + for (i = 0; i < MAX_CONST_I; ++i) + { snprintf(glsl_name, sizeof(glsl_name), "VI[%i]", i); entry->vuniformI_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name)); } - entry->puniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * GL_LIMITS(ps_glsl_constantsF)); - for (i = 0; i < GL_LIMITS(ps_glsl_constantsF); ++i) { + entry->puniformF_locations = HeapAlloc(GetProcessHeap(), 0, sizeof(GLhandleARB) * gl_info->max_ps_glsl_constantsF); + for (i = 0; i < gl_info->max_ps_glsl_constantsF; ++i) + { snprintf(glsl_name, sizeof(glsl_name), "PC[%i]", i); entry->puniformF_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name)); } - for (i = 0; i < MAX_CONST_I; ++i) { + for (i = 0; i < MAX_CONST_I; ++i) + { snprintf(glsl_name, sizeof(glsl_name), "PI[%i]", i); entry->puniformI_locations[i] = GL_EXTCALL(glGetUniformLocationARB(programId, glsl_name)); } @@ -4521,7 +4531,7 @@ static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; struct shader_glsl_priv *priv = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct shader_glsl_priv)); - SIZE_T stack_size = wined3d_log2i(max(GL_LIMITS(vs_glsl_constantsF), GL_LIMITS(ps_glsl_constantsF))) + 1; + SIZE_T stack_size = wined3d_log2i(max(gl_info->max_vs_glsl_constantsF, gl_info->max_ps_glsl_constantsF)) + 1; if (!shader_buffer_init(&priv->shader_buffer)) { @@ -4536,13 +4546,13 @@ static HRESULT shader_glsl_alloc(IWineD3DDevice *iface) { goto fail; } - if (!constant_heap_init(&priv->vconst_heap, GL_LIMITS(vs_glsl_constantsF))) + if (!constant_heap_init(&priv->vconst_heap, gl_info->max_vs_glsl_constantsF)) { ERR("Failed to initialize vertex shader constant heap\n"); goto fail; } - if (!constant_heap_init(&priv->pconst_heap, GL_LIMITS(ps_glsl_constantsF))) + if (!constant_heap_init(&priv->pconst_heap, gl_info->max_ps_glsl_constantsF)) { ERR("Failed to initialize pixel shader constant heap\n"); goto fail; @@ -4617,7 +4627,7 @@ static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, else pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0); TRACE_(d3d_caps)("Hardware vertex shader version %d.%d enabled (GLSL)\n", (pCaps->VertexShaderVersion >> 8) & 0xff, pCaps->VertexShaderVersion & 0xff); - pCaps->MaxVertexShaderConst = GL_LIMITS(vs_glsl_constantsF); + pCaps->MaxVertexShaderConst = gl_info->max_vs_glsl_constantsF; /* Older DX9-class videocards (GeforceFX / Radeon >9500/X*00) only support pixel shader 2.0/2.0a/2.0b. * In OpenGL the extensions related to GLSL abstract lowlevel GL info away which is needed @@ -4636,7 +4646,7 @@ static void shader_glsl_get_caps(WINED3DDEVTYPE devtype, else pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0); - pCaps->MaxPixelShaderConst = GL_LIMITS(ps_glsl_constantsF); + pCaps->MaxPixelShaderConst = gl_info->max_ps_glsl_constantsF; /* FIXME: The following line is card dependent. -8.0 to 8.0 is the * Direct3D minimum requirement. diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index a0a576be184..63bc1a0cb31 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -458,6 +458,7 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage); + const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Setting color op for stage %d\n", stage); @@ -468,7 +469,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct if (mapped_stage != WINED3D_UNMAPPED_STAGE) { - if (tex_used && mapped_stage >= GL_LIMITS(textures)) { + if (tex_used && mapped_stage >= gl_info->max_textures) + { FIXME("Attempt to enable unsupported stage!\n"); return; } @@ -499,7 +501,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } - if(GL_SUPPORT(NV_TEXTURE_SHADER2) && mapped_stage < GL_LIMITS(textures)) { + if (gl_info->supported[NV_TEXTURE_SHADER2] && mapped_stage < gl_info->max_textures) + { glTexEnvi(GL_TEXTURE_SHADER_NV, GL_SHADER_OPERATION_NV, GL_NONE); } } @@ -555,7 +558,7 @@ static void nvts_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop * will take care of this business */ - if(mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= GL_LIMITS(textures)) return; + if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->max_textures) return; if(sampler >= stateblock->lowest_disabled_stage) return; if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; @@ -574,7 +577,8 @@ static void nvts_bumpenvmat(DWORD state, IWineD3DStateBlockImpl *stateblock, str * map is read from a specified source stage(always stage - 1 for d3d). Thus set the matrix * for stage + 1. Keep the nvrc tex unit mapping in mind too */ - if(mapped_stage < GL_LIMITS(textures)) { + if (mapped_stage < context->gl_info->max_textures) + { GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage))"); @@ -658,8 +662,8 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_PREMODULATE */ #endif - pCaps->MaxTextureBlendStages = GL_LIMITS(texture_stages); - pCaps->MaxSimultaneousTextures = GL_LIMITS(textures); + pCaps->MaxTextureBlendStages = gl_info->max_texture_stages; + pCaps->MaxSimultaneousTextures = gl_info->max_textures; pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_TSSARGTEMP; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 822c2693c86..bb6f1da2283 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -653,6 +653,7 @@ static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struc static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { + const struct wined3d_gl_info *gl_info = context->gl_info; /* Originally this used glLightModeli(GL_LIGHT_MODEL_COLOR_CONTROL,GL_SEPARATE_SPECULAR_COLOR) * and (GL_LIGHT_MODEL_COLOR_CONTROL,GL_SINGLE_COLOR) to swap between enabled/disabled * specular color. This is wrong: @@ -688,15 +689,16 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, (float*) &stateblock->material.Specular); checkGLcall("glMaterialfv"); - if(stateblock->material.Power > GL_LIMITS(shininess)) { + if (stateblock->material.Power > gl_info->max_shininess) + { /* glMaterialf man page says that the material says that GL_SHININESS must be between 0.0 * and 128.0, although in d3d neither -1 nor 129 produce an error. GL_NV_max_light_exponent - * allows bigger values. If the extension is supported, GL_LIMITS(shininess) contains the - * value reported by the extension, otherwise 128. For values > GL_LIMITS(shininess) clamp + * allows bigger values. If the extension is supported, gl_info->max_shininess contains the + * value reported by the extension, otherwise 128. For values > gl_info->max_shininess clamp * them, it should be safe to do so without major visual distortions. */ - WARN("Material power = %f, limit %f\n", stateblock->material.Power, GL_LIMITS(shininess)); - glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, GL_LIMITS(shininess)); + WARN("Material power = %f, limit %f\n", stateblock->material.Power, gl_info->max_shininess); + glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, gl_info->max_shininess); } else { glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, stateblock->material.Power); } @@ -762,7 +764,8 @@ static void state_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, str D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col); /* And now the default texture color as well */ - for (i = 0; i < GL_LIMITS(texture_stages); i++) { + for (i = 0; i < context->gl_info->max_texture_stages; ++i) + { /* Note the WINED3DRS value applies to all textures, but GL has one * per texture, so apply it now ready to be used! */ @@ -1421,6 +1424,7 @@ static void state_psizemin_arb(DWORD state, IWineD3DStateBlockImpl *stateblock, static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { + const struct wined3d_gl_info *gl_info = context->gl_info; /* TODO: Group this with the viewport */ /* * POINTSCALEENABLE controls how point size value is treated. If set to @@ -1444,27 +1448,29 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct GLfloat scaleFactor; float h = stateblock->viewport.Height; - if(pointSize.f < GL_LIMITS(pointsizemin)) { - /* - * Minimum valid point size for OpenGL is driver specific. For Direct3D it is + if (pointSize.f < gl_info->max_pointsizemin) + { + /* Minimum valid point size for OpenGL is driver specific. For Direct3D it is * 0.0f. This means that OpenGL will clamp really small point sizes to the * driver minimum. To correct for this we need to multiply by the scale factor when sizes * are less than 1.0f. scale_factor = 1.0f / point_size. */ - scaleFactor = pointSize.f / GL_LIMITS(pointsizemin); + scaleFactor = pointSize.f / gl_info->max_pointsizemin; /* Clamp the point size, don't rely on the driver to do it. MacOS says min point size * is 1.0, but then accepts points below that and draws too small points */ - pointSize.f = GL_LIMITS(pointsizemin); - } else if(pointSize.f > GL_LIMITS(pointsize)) { + pointSize.f = gl_info->max_pointsizemin; + } + else if(pointSize.f > gl_info->max_pointsize) + { /* gl already scales the input to glPointSize, * d3d scales the result after the point size scale. * If the point size is bigger than the max size, use the * scaling to scale it bigger, and set the gl point size to max */ - scaleFactor = pointSize.f / GL_LIMITS(pointsize); + scaleFactor = pointSize.f / gl_info->max_pointsize; TRACE("scale: %f\n", scaleFactor); - pointSize.f = GL_LIMITS(pointsize); + pointSize.f = gl_info->max_pointsize; } else { scaleFactor = 1.0f; } @@ -1561,11 +1567,16 @@ static void state_pointsprite_w(DWORD state, IWineD3DStateBlockImpl *stateblock, static void state_pointsprite(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { - if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) { + const struct wined3d_gl_info *gl_info = context->gl_info; + + if (stateblock->renderState[WINED3DRS_POINTSPRITEENABLE]) + { static BOOL warned; - if(GL_LIMITS(point_sprite_units) < GL_LIMITS(textures) && !warned) { - if(use_ps(stateblock) || stateblock->lowest_disabled_stage > GL_LIMITS(point_sprite_units)) { + if (gl_info->max_point_sprite_units < gl_info->max_textures && !warned) + { + if (use_ps(stateblock) || stateblock->lowest_disabled_stage > gl_info->max_point_sprite_units) + { FIXME("The app uses point sprite texture coordinates on more units than supported by the driver\n"); warned = TRUE; } @@ -2931,6 +2942,7 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct DWORD stage = (state - STATE_TEXTURESTAGE(0, 0)) / (WINED3D_HIGHEST_TEXTURE_STATE + 1); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[stage]; BOOL tex_used = stateblock->wineD3DDevice->fixed_function_usage_map & (1 << stage); + const struct wined3d_gl_info *gl_info = context->gl_info; TRACE("Setting color op for stage %d\n", stage); @@ -2941,7 +2953,8 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct if (mapped_stage != WINED3D_UNMAPPED_STAGE) { - if (tex_used && mapped_stage >= GL_LIMITS(textures)) { + if (tex_used && mapped_stage >= gl_info->max_textures) + { FIXME("Attempt to enable unsupported stage!\n"); return; } @@ -2996,7 +3009,8 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d /* Do not care for enabled / disabled stages, just assign the settings. colorop disables / enables required stuff */ if (mapped_stage != WINED3D_UNMAPPED_STAGE) { - if (tex_used && mapped_stage >= GL_LIMITS(textures)) { + if (tex_used && mapped_stage >= context->gl_info->max_textures) + { FIXME("Attempt to enable unsupported stage!\n"); return; } @@ -3100,10 +3114,8 @@ static void transform_texture(DWORD state, IWineD3DStateBlockImpl *stateblock, s } if (mapped_stage == WINED3D_UNMAPPED_STAGE) return; + if (mapped_stage >= context->gl_info->max_textures) return; - if(mapped_stage >= GL_LIMITS(textures)) { - return; - } GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); checkGLcall("glActiveTextureARB"); generated = (stateblock->textureState[texUnit][WINED3DTSS_TEXCOORDINDEX] & 0xFFFF0000) != WINED3DTSS_TCI_PASSTHRU; @@ -3135,7 +3147,8 @@ static void unloadTexCoords(const struct wined3d_context *context) { unsigned int texture_idx; - for (texture_idx = 0; texture_idx < GL_LIMITS(texture_stages); ++texture_idx) { + for (texture_idx = 0; texture_idx < context->gl_info->max_texture_stages; ++texture_idx) + { GL_EXTCALL(glClientActiveTextureARB(GL_TEXTURE0_ARB + texture_idx)); glDisableClientState(GL_TEXTURE_COORD_ARRAY); } @@ -3148,7 +3161,8 @@ static void loadTexCoords(const struct wined3d_context *context, IWineD3DStateBl unsigned int mapped_stage = 0; unsigned int textureNo = 0; - for (textureNo = 0; textureNo < GL_LIMITS(texture_stages); ++textureNo) { + for (textureNo = 0; textureNo < context->gl_info->max_texture_stages; ++textureNo) + { int coordIdx = stateblock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX]; mapped_stage = stateblock->wineD3DDevice->texUnitMap[textureNo]; @@ -3181,7 +3195,8 @@ static void loadTexCoords(const struct wined3d_context *context, IWineD3DStateBl } if (GL_SUPPORT(NV_REGISTER_COMBINERS)) { /* The number of the mapped stages increases monotonically, so it's fine to use the last used one */ - for (textureNo = mapped_stage + 1; textureNo < GL_LIMITS(textures); ++textureNo) { + for (textureNo = mapped_stage + 1; textureNo < context->gl_info->max_textures; ++textureNo) + { GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + textureNo, 0, 0, 0, 1)); } } @@ -3204,7 +3219,8 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru return; } - if(mapped_stage >= GL_LIMITS(fragment_samplers)) { + if (mapped_stage >= context->gl_info->max_fragment_samplers) + { WARN("stage %u not mapped to a valid texture unit (%u)\n", stage, mapped_stage); return; } @@ -3426,6 +3442,7 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine { DWORD sampler = state - STATE_SAMPLER(0); DWORD mapped_stage = stateblock->wineD3DDevice->texUnitMap[sampler]; + const struct wined3d_gl_info *gl_info = context->gl_info; union { float f; DWORD d; @@ -3442,7 +3459,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine return; } - if (mapped_stage >= GL_LIMITS(combined_samplers)) { + if (mapped_stage >= gl_info->max_combined_samplers) + { return; } GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + mapped_stage)); @@ -3480,7 +3498,9 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine d3ddevice->shader_backend->shader_load_np2fixup_constants( (IWineD3DDevice*)d3ddevice, use_ps(stateblock), use_vs(stateblock)); } - } else if(mapped_stage < GL_LIMITS(textures)) { + } + else if (mapped_stage < gl_info->max_textures) + { if(sampler < stateblock->lowest_disabled_stage) { /* TODO: What should I do with pixel shaders here ??? */ if(stateblock->renderState[WINED3DRS_COLORKEYENABLE] && sampler == 0) { @@ -3590,7 +3610,8 @@ static void clipplane(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi { UINT index = state - STATE_CLIPPLANE(0); - if(isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW)) || index >= GL_LIMITS(clipplanes)) { + if (isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW)) || index >= context->gl_info->max_clipplanes) + { return; } @@ -3627,7 +3648,8 @@ static void transform_worldex(DWORD state, IWineD3DStateBlockImpl *stateblock, s GLenum glMat; TRACE("Setting world matrix %d\n", matrix); - if(matrix >= GL_LIMITS(blends)) { + if (matrix >= context->gl_info->max_blends) + { WARN("Unsupported blend matrix set\n"); return; } else if(isStateDirty(context, STATE_TRANSFORM(WINED3DTS_VIEW))) { @@ -3699,8 +3721,10 @@ static void state_vertexblend(DWORD state, IWineD3DStateBlockImpl *stateblock, s if(!stateblock->wineD3DDevice->vertexBlendUsed) { unsigned int i; - for(i = 1; i < GL_LIMITS(blends); i++) { - if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i)))) { + for (i = 1; i < context->gl_info->max_blends; ++i) + { + if (!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i)))) + { transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(i)), stateblock, context); } } @@ -3751,7 +3775,8 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, stru } /* Reset Clipping Planes */ - for (k = 0; k < GL_LIMITS(clipplanes); k++) { + for (k = 0; k < context->gl_info->max_clipplanes; ++k) + { if(!isStateDirty(context, STATE_CLIPPLANE(k))) { clipplane(STATE_CLIPPLANE(k), stateblock, context); } @@ -3773,7 +3798,8 @@ static void transform_view(DWORD state, IWineD3DStateBlockImpl *stateblock, stru /* Avoid looping over a number of matrices if the app never used the functionality */ if(stateblock->wineD3DDevice->vertexBlendUsed) { - for(k = 1; k < GL_LIMITS(blends); k++) { + for (k = 1; k < context->gl_info->max_blends; ++k) + { if(!isStateDirty(context, STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k)))) { transform_worldex(STATE_TRANSFORM(WINED3DTS_WORLDMATRIX(k)), stateblock, context); } @@ -4203,7 +4229,7 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB if (GL_SUPPORT(ARB_VERTEX_BLEND)) { static const GLbyte one = 1; GL_EXTCALL(glWeightbvARB(1, &one)); - checkGLcall("glWeightivARB(GL_LIMITS(blends), weights)"); + checkGLcall("glWeightivARB(gl_info->max_blends, weights)"); } } @@ -4484,6 +4510,7 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { + const struct wined3d_gl_info *gl_info = context->gl_info; BOOL updateFog = FALSE; BOOL useVertexShaderFunction = use_vs(stateblock); BOOL usePixelShaderFunction = use_ps(stateblock); @@ -4565,7 +4592,8 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s if(!device->vs_clipping && !isStateDirty(context, STATE_RENDER(WINED3DRS_CLIPPLANEENABLE))) { state_clipping(STATE_RENDER(WINED3DRS_CLIPPLANEENABLE), stateblock, context); } - for(i = 0; i < GL_LIMITS(clipplanes); i++) { + for (i = 0; i < gl_info->max_clipplanes; ++i) + { clipplane(STATE_CLIPPLANE(i), stateblock, context); } } @@ -4579,7 +4607,8 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s /* Disable all clip planes to get defined results on all drivers. See comment in the * state_clipping state handler */ - for(i = 0; i < GL_LIMITS(clipplanes); i++) { + for (i = 0; i < gl_info->max_clipplanes; ++i) + { glDisable(GL_CLIP_PLANE0 + i); checkGLcall("glDisable(GL_CLIP_PLANE0 + i)"); } @@ -4608,7 +4637,8 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, s * (Note: ARB shaders can read the clip planes for clipping emulation even if * device->vs_clipping is false. */ - for(i = 0; i < GL_LIMITS(clipplanes); i++) { + for (i = 0; i < gl_info->max_clipplanes; ++i) + { clipplane(STATE_CLIPPLANE(i), stateblock, context); } } @@ -5563,8 +5593,8 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3)) pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3; - pCaps->MaxTextureBlendStages = GL_LIMITS(texture_stages); - pCaps->MaxSimultaneousTextures = GL_LIMITS(textures); + pCaps->MaxTextureBlendStages = gl_info->max_texture_stages; + pCaps->MaxSimultaneousTextures = gl_info->max_textures; } static HRESULT ffp_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; } diff --git a/dlls/wined3d/stateblock.c b/dlls/wined3d/stateblock.c index f6ede2cd1b9..da1df21984e 100644 --- a/dlls/wined3d/stateblock.c +++ b/dlls/wined3d/stateblock.c @@ -194,25 +194,31 @@ static const DWORD vertex_states_sampler[] = */ static HRESULT stateblock_allocate_shader_constants(IWineD3DStateBlockImpl *object) { - IWineD3DStateBlockImpl *This = object; + const struct wined3d_gl_info *gl_info = &object->wineD3DDevice->adapter->gl_info; /* Allocate space for floating point constants */ - object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(pshader_constantsF) * 4); + object->pixelShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(float) * gl_info->max_pshader_constantsF * 4); if (!object->pixelShaderConstantF) goto fail; - object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(pshader_constantsF)); + object->changed.pixelShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(BOOL) * gl_info->max_pshader_constantsF); if (!object->changed.pixelShaderConstantsF) goto fail; - object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(float) * GL_LIMITS(vshader_constantsF) * 4); + object->vertexShaderConstantF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(float) * gl_info->max_vshader_constantsF * 4); if (!object->vertexShaderConstantF) goto fail; - object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(BOOL) * GL_LIMITS(vshader_constantsF)); + object->changed.vertexShaderConstantsF = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, + sizeof(BOOL) * gl_info->max_vshader_constantsF); if (!object->changed.vertexShaderConstantsF) goto fail; - object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(vshader_constantsF)); + object->contained_vs_consts_f = HeapAlloc(GetProcessHeap(), 0, + sizeof(DWORD) * gl_info->max_vshader_constantsF); if (!object->contained_vs_consts_f) goto fail; - object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, sizeof(DWORD) * GL_LIMITS(pshader_constantsF)); + object->contained_ps_consts_f = HeapAlloc(GetProcessHeap(), 0, + sizeof(DWORD) * gl_info->max_pshader_constantsF); if (!object->contained_ps_consts_f) goto fail; return WINED3D_OK; @@ -1058,6 +1064,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat IWineD3DStateBlockImpl *This = (IWineD3DStateBlockImpl *)iface; IWineD3DDevice *device = (IWineD3DDevice *)This->wineD3DDevice; IWineD3DDeviceImpl *ThisDevice = (IWineD3DDeviceImpl *)device; + const struct wined3d_gl_info *gl_info = &This->wineD3DDevice->adapter->gl_info; union { WINED3DLINEPATTERN lp; DWORD d; @@ -1171,7 +1178,7 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat tmpfloat.f = 1.0f; IWineD3DDevice_SetRenderState(device, WINED3DRS_PATCHSEGMENTS, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_DEBUGMONITORTOKEN, 0xbaadcafe); - tmpfloat.f = GL_LIMITS(pointsize); + tmpfloat.f = gl_info->max_pointsize; IWineD3DDevice_SetRenderState(device, WINED3DRS_POINTSIZE_MAX, tmpfloat.d); IWineD3DDevice_SetRenderState(device, WINED3DRS_INDEXEDVERTEXBLENDENABLE, FALSE); IWineD3DDevice_SetRenderState(device, WINED3DRS_COLORWRITEENABLE, 0x0000000F); @@ -1265,7 +1272,8 @@ static HRESULT WINAPI IWineD3DStateBlockImpl_InitStartupStateBlock(IWineD3DStat This->samplerState[i][WINED3DSAMP_DMAPOFFSET ] = 0; /* TODO: Vertex offset in the presampled displacement map */ } - for(i = 0; i < GL_LIMITS(textures); i++) { + for (i = 0; i < gl_info->max_textures; ++i) + { /* Note: This avoids calling SetTexture, so pretend it has been called */ This->changed.textures |= 1 << i; This->textures[i] = NULL; diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index c0e0e10a1e1..7e69d7d84bd 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -4115,6 +4115,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_RealizePalette(IWineD3DSurface *iface) static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) { /** Check against the maximum texture sizes supported by the video card **/ IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; + const struct wined3d_gl_info *gl_info = &This->resource.wineD3DDevice->adapter->gl_info; unsigned int pow2Width, pow2Height; This->texture_name = 0; @@ -4149,7 +4150,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) { } TRACE("%p\n", This); - if ((This->pow2Width > GL_LIMITS(texture_size) || This->pow2Height > GL_LIMITS(texture_size)) && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) { + if ((This->pow2Width > gl_info->max_texture_size || This->pow2Height > gl_info->max_texture_size) + && !(This->resource.usage & (WINED3DUSAGE_RENDERTARGET | WINED3DUSAGE_DEPTHSTENCIL))) + { /* one of three options 1: Do the same as we do with nonpow 2 and scale the texture, (any texture ops would require the texture to be scaled which is potentially slow) 2: Set the texture to the maximum size (bad idea) diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index 3f736c79132..bbf9109041e 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -916,7 +916,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info) TRACE("Nvidia card with texture_float support: Assuming float16 blending\n"); filtered = TRUE; } - else if(GL_LIMITS(glsl_varyings > 44)) + else if (gl_info->max_glsl_varyings > 44) { TRACE("More than 44 GLSL varyings - assuming d3d10 card with float16 blending\n"); filtered = TRUE; @@ -1140,10 +1140,6 @@ fail: return FALSE; } -#undef GLINFO_LOCATION - -#define GLINFO_LOCATION This->adapter->gl_info - const struct GlPixelFormatDesc *getFormatDescEntry(WINED3DFORMAT fmt, const struct wined3d_gl_info *gl_info) { int idx = getFmtIdx(fmt); @@ -2028,7 +2024,6 @@ void set_texture_matrix(const float *smat, DWORD flags, BOOL calculatedCoords, B glLoadMatrixf(mat); checkGLcall("glLoadMatrixf(mat)"); } -#undef GLINFO_LOCATION /* This small helper function is used to convert a bitmask into the number of masked bits */ unsigned int count_bits(unsigned int mask) @@ -2192,12 +2187,12 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) { * FALSE otherwise * *********************************************************************/ -#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info - -BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) { +BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) +{ + const struct wined3d_gl_info *gl_info = &This->resource.wineD3DDevice->adapter->gl_info; int x1 = Rect->left, x2 = Rect->right; int y1 = Rect->top, y2 = Rect->bottom; - GLint maxSize = GL_LIMITS(texture_size); + GLint maxSize = gl_info->max_texture_size; TRACE("(%p)->(%d,%d)-(%d,%d)\n", This, Rect->left, Rect->top, Rect->right, Rect->bottom); @@ -2281,7 +2276,7 @@ BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4] } if(This->pow2Height > maxSize) { - This->glRect.top = x1 - GL_LIMITS(texture_size) / 2; + This->glRect.top = x1 - gl_info->max_texture_size / 2; if(This->glRect.top < 0) This->glRect.top = 0; This->glRect.bottom = This->glRect.left + maxSize; if(This->glRect.bottom > This->currentDesc.Height) { @@ -2315,9 +2310,7 @@ BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4] } return TRUE; } -#undef GLINFO_LOCATION -#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_settings *settings, BOOL ignore_textype) { #define ARG1 0x01 #define ARG2 0x02 @@ -2355,8 +2348,10 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting DWORD ttff; DWORD cop, aop, carg0, carg1, carg2, aarg0, aarg1, aarg2; IWineD3DDeviceImpl *device = stateblock->wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - for(i = 0; i < GL_LIMITS(texture_stages); i++) { + for (i = 0; i < gl_info->max_texture_stages; ++i) + { IWineD3DBaseTextureImpl *texture; settings->op[i].padding = 0; if(stateblock->textureState[i][WINED3DTSS_COLOROP] == WINED3DTOP_DISABLE) { @@ -2557,7 +2552,6 @@ void gen_ffp_frag_op(IWineD3DStateBlockImpl *stateblock, struct ffp_frag_setting settings->emul_clipplanes = 1; } } -#undef GLINFO_LOCATION const struct ffp_frag_desc *find_ffp_frag_shader(const struct wine_rb_tree *fragment_shaders, const struct ffp_frag_settings *settings) @@ -2580,11 +2574,13 @@ void add_ffp_frag_shader(struct wine_rb_tree *shaders, struct ffp_frag_desc *des * Does not care for the colorop or correct gl texture unit(when using nvrc) * Requires the caller to activate the correct unit before */ -#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info /* GL locking is done by the caller (state handler) */ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock, struct wined3d_context *context) { - if(stateblock->textures[stage]) { + const struct wined3d_gl_info *gl_info = context->gl_info; + + if (stateblock->textures[stage]) + { switch (IWineD3DBaseTexture_GetTextureDimensions(stateblock->textures[stage])) { case GL_TEXTURE_2D: glDisable(GL_TEXTURE_3D); @@ -2666,13 +2662,12 @@ void sampler_texdim(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine * handler takes care. Also no action is needed with pixel shaders, or if tex_colorop * will take care of this business */ - if(mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= GL_LIMITS(textures)) return; + if (mapped_stage == WINED3D_UNMAPPED_STAGE || mapped_stage >= context->gl_info->max_textures) return; if(sampler >= stateblock->lowest_disabled_stage) return; if(isStateDirty(context, STATE_TEXTURESTAGE(sampler, WINED3DTSS_COLOROP))) return; texture_activate_dimensions(sampler, stateblock, context); } -#undef GLINFO_LOCATION void *wined3d_rb_alloc(size_t size) { diff --git a/dlls/wined3d/vertexshader.c b/dlls/wined3d/vertexshader.c index f55f1fb09a6..2a11dae1e26 100644 --- a/dlls/wined3d/vertexshader.c +++ b/dlls/wined3d/vertexshader.c @@ -37,6 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader); static void vshader_set_limits(IWineD3DVertexShaderImpl *This) { + const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; DWORD shader_version = WINED3D_SHADER_VERSION(This->baseShader.reg_maps.shader_version.major, This->baseShader.reg_maps.shader_version.minor); @@ -57,7 +58,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.label = 0; /* TODO: vs_1_1 has a minimum of 96 constants. What happens if a vs_1_1 shader is used * on a vs_3_0 capable card that has 256 constants? */ - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, gl_info->max_vshader_constantsF); break; case WINED3D_SHADER_VERSION(2,0): @@ -69,7 +70,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.packed_output = 0; This->baseShader.limits.sampler = 0; This->baseShader.limits.label = 16; - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, gl_info->max_vshader_constantsF); break; case WINED3D_SHADER_VERSION(4,0): @@ -88,7 +89,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) * of supporting much more(GL drivers advertise 1024). d3d9.dll and d3d8.dll clamp the * wined3d-advertised maximum. Clamp the constant limit for <= 3.0 shaders to 256.s * use constant buffers */ - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, gl_info->max_vshader_constantsF); break; default: @@ -99,7 +100,7 @@ static void vshader_set_limits(IWineD3DVertexShaderImpl *This) This->baseShader.limits.packed_output = 0; This->baseShader.limits.sampler = 0; This->baseShader.limits.label = 16; - This->baseShader.limits.constant_float = min(256, GL_LIMITS(vshader_constantsF)); + This->baseShader.limits.constant_float = min(256, gl_info->max_vshader_constantsF); FIXME("Unrecognized vertex shader version %u.%u\n", This->baseShader.reg_maps.shader_version.major, This->baseShader.reg_maps.shader_version.minor); @@ -316,14 +317,16 @@ static HRESULT vertexshader_set_function(IWineD3DVertexShaderImpl *shader, static HRESULT WINAPI IWIneD3DVertexShaderImpl_SetLocalConstantsF(IWineD3DVertexShader *iface, UINT start_idx, const float *src_data, UINT count) { IWineD3DVertexShaderImpl *This =(IWineD3DVertexShaderImpl *)iface; + const struct wined3d_gl_info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info; UINT i, end_idx; TRACE("(%p) : start_idx %u, src_data %p, count %u\n", This, start_idx, src_data, count); end_idx = start_idx + count; - if (end_idx > GL_LIMITS(vshader_constantsF)) { - WARN("end_idx %u > float constants limit %u\n", end_idx, GL_LIMITS(vshader_constantsF)); - end_idx = GL_LIMITS(vshader_constantsF); + if (end_idx > gl_info->max_vshader_constantsF) + { + WARN("end_idx %u > float constants limit %u\n", end_idx, gl_info->max_vshader_constantsF); + end_idx = gl_info->max_vshader_constantsF; } for (i = start_idx; i < end_idx; ++i) { diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index e293d0f4878..bafdc028c6c 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -753,7 +753,6 @@ extern int num_lock DECLSPEC_HIDDEN; /* GL related defines */ /* ------------------ */ #define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0) -#define GL_LIMITS(ExtName) (GLINFO_LOCATION.max_##ExtName) #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName) #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)