diff --git a/dlls/wined3d/arb_program_shader.c b/dlls/wined3d/arb_program_shader.c index 49df9cb2a12..2066dda8620 100644 --- a/dlls/wined3d/arb_program_shader.c +++ b/dlls/wined3d/arb_program_shader.c @@ -46,22 +46,22 @@ static BOOL need_mova_const(IWineD3DBaseShader *shader, const struct wined3d_gl_ { IWineD3DBaseShaderImpl *This = (IWineD3DBaseShaderImpl *) shader; if(!This->baseShader.reg_maps.usesmova) return FALSE; - return !GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION); + return !gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]; } /* Returns TRUE if result.clip from GL_NV_vertex_program2 should be used and FALSE otherwise */ static inline BOOL use_nv_clip(const struct wined3d_gl_info *gl_info) { - return GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION) && - !(gl_info->quirks & WINED3D_QUIRK_NV_CLIP_BROKEN); + return gl_info->supported[NV_VERTEX_PROGRAM2_OPTION] + && !(gl_info->quirks & WINED3D_QUIRK_NV_CLIP_BROKEN); } static BOOL need_helper_const(const struct wined3d_gl_info *gl_info) { - if (!GL_SUPPORT(NV_VERTEX_PROGRAM) /* Need to init colors. */ - || gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT /* Load the immval offset. */ - || gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W /* Have to init texcoords. */ - || (!use_nv_clip(gl_info)) /* Init the clip texcoord */) + if (!gl_info->supported[NV_VERTEX_PROGRAM] /* Need to init colors. */ + || gl_info->quirks & WINED3D_QUIRK_ARB_VS_OFFSET_LIMIT /* Load the immval offset. */ + || gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W /* Have to init texcoords. */ + || (!use_nv_clip(gl_info)) /* Init the clip texcoord */) { return TRUE; } @@ -328,7 +328,8 @@ static unsigned int shader_arb_load_constantsF(IWineD3DBaseShaderImpl *This, con */ } - if(GL_SUPPORT(EXT_GPU_PROGRAM_PARAMETERS)) { + if (gl_info->supported[EXT_GPU_PROGRAM_PARAMETERS]) + { /* TODO: Benchmark if we're better of with finding the dirty constants ourselves, * or just reloading *all* constants at once * @@ -3330,10 +3331,13 @@ static GLuint shader_arb_generate_pshader(IWineD3DPixelShaderImpl *This, struct } shader_addline(buffer, "!!ARBfp1.0\n"); - if(want_nv_prog && GL_SUPPORT(NV_FRAGMENT_PROGRAM2)) { + if (want_nv_prog && gl_info->supported[NV_FRAGMENT_PROGRAM2]) + { shader_addline(buffer, "OPTION NV_fragment_program2;\n"); priv_ctx.target_version = NV3; - } else if(want_nv_prog && GL_SUPPORT(NV_FRAGMENT_PROGRAM_OPTION)) { + } + else if (want_nv_prog && gl_info->supported[NV_FRAGMENT_PROGRAM_OPTION]) + { shader_addline(buffer, "OPTION NV_fragment_program;\n"); priv_ctx.target_version = NV2; } else { @@ -3855,11 +3859,14 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct /* Always enable the NV extension if available. Unlike fragment shaders, there is no * mesurable performance penalty, and we can always make use of it for clipplanes. */ - if(GL_SUPPORT(NV_VERTEX_PROGRAM3)) { + if (gl_info->supported[NV_VERTEX_PROGRAM3]) + { shader_addline(buffer, "OPTION NV_vertex_program3;\n"); priv_ctx.target_version = NV3; shader_addline(buffer, "ADDRESS aL;\n"); - } else if(GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION)) { + } + else if (gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) + { shader_addline(buffer, "OPTION NV_vertex_program2;\n"); priv_ctx.target_version = NV2; shader_addline(buffer, "ADDRESS aL;\n"); @@ -3918,7 +3925,8 @@ static GLuint shader_arb_generate_vshader(IWineD3DVertexShaderImpl *This, struct * coords, we have a flag in the opengl caps. Many cards do not require the texcoord being set, and * this can eat a number of instructions, so skip it unless this cap is set as well */ - if(!GL_SUPPORT(NV_VERTEX_PROGRAM)) { + if (!gl_info->supported[NV_VERTEX_PROGRAM]) + { shader_addline(buffer, "MOV result.color.secondary, -helper_const.wwwy;\n"); if (gl_info->quirks & WINED3D_QUIRK_SET_TEXCOORD_W && !device->frag_pipe->ffp_proj_control) @@ -4099,7 +4107,9 @@ static struct arb_vs_compiled_shader *find_arb_vshader(IWineD3DVertexShaderImpl * (cache coherency etc) */ for(i = 0; i < shader_data->num_gl_shaders; i++) { - if(vs_args_equal(&shader_data->gl_shaders[i].args, args, use_map, GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION))) { + if (vs_args_equal(&shader_data->gl_shaders[i].args, args, + use_map, gl_info->supported[NV_VERTEX_PROGRAM2_OPTION])) + { return &shader_data->gl_shaders[i]; } } @@ -4173,7 +4183,7 @@ static inline void find_arb_ps_compile_args(IWineD3DPixelShaderImpl *shader, IWi /* Skip if unused or local, or supported natively */ int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts; - if(int_skip == 0xffff || GL_SUPPORT(NV_FRAGMENT_PROGRAM_OPTION)) + if (int_skip == 0xffff || gl_info->supported[NV_FRAGMENT_PROGRAM_OPTION]) { memset(&args->loop_ctrl, 0, sizeof(args->loop_ctrl)); return; @@ -4248,7 +4258,8 @@ static inline void find_arb_vs_compile_args(IWineD3DVertexShaderImpl *shader, IW /* Skip if unused or local */ int_skip = ~shader->baseShader.reg_maps.integer_constants | shader->baseShader.reg_maps.local_int_consts; - if(int_skip == 0xffff || GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION)) /* This is about flow control, not clipping */ + /* This is about flow control, not clipping. */ + if (int_skip == 0xffff || gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) { memset(&args->loop_ctrl, 0, sizeof(args->loop_ctrl)); return; @@ -4324,7 +4335,9 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, /* Force constant reloading for the NP2 fixup (see comment in shader_glsl_select for more info) */ if (compiled->np2fixup_info.super.active) shader_arb_load_np2fixup_constants((IWineD3DDevice *)This, usePS, useVS); - } else if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && !priv->use_arbfp_fixed_func) { + } + else if (gl_info->supported[ARB_FRAGMENT_PROGRAM] && !priv->use_arbfp_fixed_func) + { /* Disable only if we're not using arbfp fixed function fragment processing. If this is used, * keep GL_FRAGMENT_PROGRAM_ARB enabled, and the fixed function pipeline will bind the fixed function * replacement shader @@ -4358,14 +4371,17 @@ static void shader_arb_select(const struct wined3d_context *context, BOOL usePS, if(priv->last_vs_color_unclamp != compiled->need_color_unclamp) { priv->last_vs_color_unclamp = compiled->need_color_unclamp; - if (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) { + if (gl_info->supported[ARB_COLOR_BUFFER_FLOAT]) + { GL_EXTCALL(glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, !compiled->need_color_unclamp)); checkGLcall("glClampColorARB"); } else { FIXME("vertex color clamp needs to be changed, but extension not supported.\n"); } } - } else if(GL_SUPPORT(ARB_VERTEX_PROGRAM)) { + } + else if (gl_info->supported[ARB_VERTEX_PROGRAM]) + { priv->current_vprogram_id = 0; glDisable(GL_VERTEX_PROGRAM_ARB); checkGLcall("glDisable(GL_VERTEX_PROGRAM_ARB)"); @@ -4550,8 +4566,9 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ */ none_shader_backend.shader_get_caps(devtype, gl_info, pCaps); - if(GL_SUPPORT(ARB_VERTEX_PROGRAM)) { - if(GL_SUPPORT(NV_VERTEX_PROGRAM3)) + if (gl_info->supported[ARB_VERTEX_PROGRAM]) + { + if (gl_info->supported[NV_VERTEX_PROGRAM3]) { pCaps->VertexShaderVersion = WINED3DVS_VERSION(3,0); TRACE_(d3d_caps)("Hardware vertex shader version 3.0 enabled (NV_VERTEX_PROGRAM3)\n"); @@ -4570,8 +4587,9 @@ static void shader_arb_get_caps(WINED3DDEVTYPE devtype, const struct wined3d_gl_ pCaps->MaxVertexShaderConst = vs_consts; } - if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { - if(GL_SUPPORT(NV_FRAGMENT_PROGRAM2)) + if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { + if (gl_info->supported[NV_FRAGMENT_PROGRAM2]) { pCaps->PixelShaderVersion = WINED3DPS_VERSION(3,0); TRACE_(d3d_caps)("Hardware pixel shader version 3.0 enabled (NV_FRAGMENT_PROGRAM2)\n"); @@ -6636,17 +6654,20 @@ static HRESULT arbfp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatD /* Context activation is done by the caller. */ static void arbfp_blit_unset(IWineD3DDevice *iface) { IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; ENTER_GL(); glDisable(GL_FRAGMENT_PROGRAM_ARB); checkGLcall("glDisable(GL_FRAGMENT_PROGRAM_ARB)"); glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } diff --git a/dlls/wined3d/basetexture.c b/dlls/wined3d/basetexture.c index dd2a82e453e..da0bd7e8c78 100644 --- a/dlls/wined3d/basetexture.c +++ b/dlls/wined3d/basetexture.c @@ -26,7 +26,6 @@ #include "wined3d_private.h" WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); -#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info HRESULT basetexture_init(IWineD3DBaseTextureImpl *texture, UINT levels, WINED3DRESOURCETYPE resource_type, IWineD3DDeviceImpl *device, UINT size, DWORD usage, const struct GlPixelFormatDesc *format_desc, @@ -478,7 +477,10 @@ void basetexture_apply_state_changes(IWineD3DBaseTexture *iface, if (gl_tex->states[WINED3DTEXSTA_MAXANISOTROPY] != aniso) { - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + + if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) { glTexParameteri(textureDimensions, GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso); checkGLcall("glTexParameteri(GL_TEXTURE_MAX_ANISOTROPY_EXT, aniso)"); diff --git a/dlls/wined3d/buffer.c b/dlls/wined3d/buffer.c index d2548c6f38d..30ae8166d1e 100644 --- a/dlls/wined3d/buffer.c +++ b/dlls/wined3d/buffer.c @@ -203,6 +203,8 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct win DWORD *stride_this_run, BOOL *float16_used) { const struct wined3d_stream_info_element *attrib = &si->elements[attrib_idx]; + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; BOOL ret = FALSE; WINED3DFORMAT format; @@ -215,7 +217,8 @@ static BOOL buffer_check_attribute(struct wined3d_buffer *This, const struct win format = attrib->format_desc->format; /* Look for newly appeared conversion */ - if (!GL_SUPPORT(ARB_HALF_FLOAT_VERTEX) && (format == WINED3DFMT_R16G16_FLOAT || format == WINED3DFMT_R16G16B16A16_FLOAT)) + if (!gl_info->supported[ARB_HALF_FLOAT_VERTEX] + && (format == WINED3DFMT_R16G16_FLOAT || format == WINED3DFMT_R16G16B16A16_FLOAT)) { ret = buffer_process_converted_attribute(This, CONV_FLOAT16_2, attrib, stride_this_run); @@ -309,6 +312,7 @@ static UINT *find_conversion_shift(struct wined3d_buffer *This, static BOOL buffer_find_decl(struct wined3d_buffer *This) { IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const struct wined3d_stream_info *si = &device->strided_streams; UINT stride_this_run = 0; BOOL float16_used = FALSE; @@ -415,7 +419,7 @@ static BOOL buffer_find_decl(struct wined3d_buffer *This) * FLOAT16s if not supported. Also, we can't iterate over the array, so use macros to generate code for all * the attributes that our current fixed function pipeline implementation cares for. */ - BOOL support_d3dcolor = GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA); + BOOL support_d3dcolor = gl_info->supported[EXT_VERTEX_ARRAY_BGRA]; ret = buffer_check_attribute(This, si, WINED3D_FFP_POSITION, TRUE, TRUE, FALSE, &stride_this_run, &float16_used) || ret; ret = buffer_check_attribute(This, si, WINED3D_FFP_NORMAL, diff --git a/dlls/wined3d/context.c b/dlls/wined3d/context.c index 3b5eea554c5..8190a0aff5b 100644 --- a/dlls/wined3d/context.c +++ b/dlls/wined3d/context.c @@ -479,7 +479,7 @@ void context_alloc_occlusion_query(struct wined3d_context *context, struct wined } else { - if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (gl_info->supported[ARB_OCCLUSION_QUERY]) { ENTER_GL(); GL_EXTCALL(glGenQueriesARB(1, &query->id)); @@ -536,7 +536,7 @@ void context_alloc_event_query(struct wined3d_context *context, struct wined3d_e } else { - if (GL_SUPPORT(APPLE_FENCE)) + if (gl_info->supported[APPLE_FENCE]) { ENTER_GL(); GL_EXTCALL(glGenFencesAPPLE(1, &query->id)); @@ -545,7 +545,7 @@ void context_alloc_event_query(struct wined3d_context *context, struct wined3d_e TRACE("Allocated event query %u in context %p.\n", query->id, context); } - else if(GL_SUPPORT(NV_FENCE)) + else if(gl_info->supported[NV_FENCE]) { ENTER_GL(); GL_EXTCALL(glGenFencesNV(1, &query->id)); @@ -673,7 +673,7 @@ static void context_destroy_gl_resources(struct wined3d_context *context) LIST_FOR_EACH_ENTRY(occlusion_query, &context->occlusion_queries, struct wined3d_occlusion_query, entry) { - if (context->valid && GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (context->valid && gl_info->supported[ARB_OCCLUSION_QUERY]) GL_EXTCALL(glDeleteQueriesARB(1, &occlusion_query->id)); occlusion_query->context = NULL; } @@ -682,8 +682,8 @@ static void context_destroy_gl_resources(struct wined3d_context *context) { if (context->valid) { - if (GL_SUPPORT(APPLE_FENCE)) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->id)); - else if (GL_SUPPORT(NV_FENCE)) GL_EXTCALL(glDeleteFencesNV(1, &event_query->id)); + if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(1, &event_query->id)); + else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(1, &event_query->id)); } event_query->context = NULL; } @@ -717,12 +717,12 @@ static void context_destroy_gl_resources(struct wined3d_context *context) GL_EXTCALL(glDeleteProgramsARB(1, &context->dummy_arbfp_prog)); } - if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (gl_info->supported[ARB_OCCLUSION_QUERY]) GL_EXTCALL(glDeleteQueriesARB(context->free_occlusion_query_count, context->free_occlusion_queries)); - if (GL_SUPPORT(APPLE_FENCE)) + if (gl_info->supported[APPLE_FENCE]) GL_EXTCALL(glDeleteFencesAPPLE(context->free_event_query_count, context->free_event_queries)); - else if (GL_SUPPORT(NV_FENCE)) + else if (gl_info->supported[NV_FENCE]) GL_EXTCALL(glDeleteFencesNV(context->free_event_query_count, context->free_event_queries)); checkGLcall("context cleanup"); @@ -1254,9 +1254,10 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface /* D3D only allows multisampling when SwapEffect is set to WINED3DSWAPEFFECT_DISCARD */ if(pPresentParms->MultiSampleType && (pPresentParms->SwapEffect == WINED3DSWAPEFFECT_DISCARD)) { - if(!GL_SUPPORT(ARB_MULTISAMPLE)) + if (!gl_info->supported[ARB_MULTISAMPLE]) ERR("The program is requesting multisampling without support!\n"); - else { + else + { ERR("Requesting MultiSampleType=%d\n", pPresentParms->MultiSampleType); numSamples = pPresentParms->MultiSampleType; } @@ -1290,7 +1291,9 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface if(oldPixelFormat == iPixelFormat) { /* We don't have to do anything as the formats are the same :) */ - } else if(oldPixelFormat && GL_SUPPORT(WGL_WINE_PIXEL_FORMAT_PASSTHROUGH)) { + } + else if (oldPixelFormat && gl_info->supported[WGL_WINE_PIXEL_FORMAT_PASSTHROUGH]) + { res = GL_EXTCALL(wglSetPixelFormatWINE(hdc, iPixelFormat, NULL)); if(!res) { @@ -1415,14 +1418,16 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface glPixelStorei(GL_UNPACK_ALIGNMENT, This->surface_alignment); checkGLcall("glPixelStorei(GL_UNPACK_ALIGNMENT, This->surface_alignment);"); - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { /* Most textures will use client storage if supported. Exceptions are non-native power of 2 textures * and textures in DIB sections(due to the memory protection). */ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)"); } - if(GL_SUPPORT(ARB_VERTEX_BLEND)) { + if (gl_info->supported[ARB_VERTEX_BLEND]) + { /* Direct3D always uses n-1 weights for n world matrices and uses 1 - sum for the last one * this is equal to GL_WEIGHT_SUM_UNITY_ARB. Enabling it doesn't do anything unless * GL_VERTEX_BLEND_ARB isn't enabled too @@ -1430,7 +1435,8 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface glEnable(GL_WEIGHT_SUM_UNITY_ARB); checkGLcall("glEnable(GL_WEIGHT_SUM_UNITY_ARB)"); } - if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + if (gl_info->supported[NV_TEXTURE_SHADER2]) + { /* 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. */ @@ -1441,7 +1447,8 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface checkGLcall("glTexEnvi(GL_TEXTURE_SHADER_NV, GL_PREVIOUS_TEXTURE_INPUT_NV, ..."); } } - if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { /* MacOS(radeon X1600 at least, but most likely others too) refuses to draw if GLSL and ARBFP are * enabled, but the currently bound arbfp program is 0. Enabling ARBFP with prog 0 is invalid, but * GLSL should bypass this. This causes problems in programs that never use the fixed function pipeline, @@ -1467,11 +1474,11 @@ struct wined3d_context *context_create(IWineD3DDeviceImpl *This, IWineD3DSurface checkGLcall("glTexEnvi(GL_POINT_SPRITE_ARB, GL_COORD_REPLACE_ARB, GL_TRUE)"); } - if (GL_SUPPORT(ARB_PROVOKING_VERTEX)) + if (gl_info->supported[ARB_PROVOKING_VERTEX]) { GL_EXTCALL(glProvokingVertex(GL_FIRST_VERTEX_CONVENTION)); } - else if (GL_SUPPORT(EXT_PROVOKING_VERTEX)) + else if (gl_info->supported[EXT_PROVOKING_VERTEX]) { GL_EXTCALL(glProvokingVertexEXT(GL_FIRST_VERTEX_CONVENTION_EXT)); } @@ -1673,13 +1680,15 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context GL_EXTCALL(glActiveTextureARB(GL_TEXTURE0_ARB + i)); checkGLcall("glActiveTextureARB"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB"); } glDisable(GL_TEXTURE_3D); checkGLcall("glDisable GL_TEXTURE_3D"); - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB"); } @@ -1702,13 +1711,15 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context sampler = This->rev_tex_unit_map[0]; - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable GL_TEXTURE_CUBE_MAP_ARB"); } glDisable(GL_TEXTURE_3D); checkGLcall("glDisable GL_TEXTURE_3D"); - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable GL_TEXTURE_RECTANGLE_ARB"); } @@ -1722,7 +1733,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context glLoadIdentity(); checkGLcall("glLoadIdentity()"); - if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) { + if (gl_info->supported[EXT_TEXTURE_LOD_BIAS]) + { glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, 0.0f); @@ -1763,7 +1775,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context glDisable(GL_SCISSOR_TEST); checkGLcall("glDisable GL_SCISSOR_TEST"); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_SCISSORTESTENABLE), StateTable); - if(GL_SUPPORT(ARB_POINT_SPRITE)) { + if (gl_info->supported[ARB_POINT_SPRITE]) + { glDisable(GL_POINT_SPRITE_ARB); checkGLcall("glDisable GL_POINT_SPRITE_ARB"); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_POINTSPRITEENABLE), StateTable); @@ -1771,7 +1784,8 @@ static inline void SetupForBlit(IWineD3DDeviceImpl *This, struct wined3d_context glColorMask(GL_TRUE, GL_TRUE,GL_TRUE,GL_TRUE); checkGLcall("glColorMask"); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_COLORWRITEENABLE), StateTable); - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (gl_info->supported[EXT_SECONDARY_COLOR]) + { glDisable(GL_COLOR_SUM_EXT); Context_MarkStateDirty(context, STATE_RENDER(WINED3DRS_SPECULARENABLE), StateTable); checkGLcall("glDisable(GL_COLOR_SUM_EXT)"); @@ -2059,7 +2073,7 @@ static void context_apply_draw_buffer(struct wined3d_context *context, BOOL blit { if (!blit) { - if (GL_SUPPORT(ARB_DRAW_BUFFERS)) + if (gl_info->supported[ARB_DRAW_BUFFERS]) { GL_EXTCALL(glDrawBuffersARB(gl_info->limits.buffers, device->draw_buffers)); checkGLcall("glDrawBuffers()"); diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c index 25df2847b90..39293480b30 100644 --- a/dlls/wined3d/device.c +++ b/dlls/wined3d/device.c @@ -298,7 +298,8 @@ void device_stream_info_from_declaration(IWineD3DDeviceImpl *This, stream_info->elements[idx].stream_idx = element->input_slot; stream_info->elements[idx].buffer_object = buffer_object; - if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) + if (!This->adapter->gl_info.supported[EXT_VERTEX_ARRAY_BGRA] + && element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << idx; } @@ -360,7 +361,7 @@ void device_stream_info_from_strided(IWineD3DDeviceImpl *This, { if (!stream_info->elements[i].format_desc) continue; - if (!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) + if (!This->adapter->gl_info.supported[EXT_VERTEX_ARRAY_BGRA] && stream_info->elements[i].format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) { stream_info->swizzle_map |= 1 << i; @@ -535,7 +536,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateVertexBuffer(IWineD3DDevice *ifac * more. In this call we can convert dx7 buffers too. */ conv = ((FVF & WINED3DFVF_POSITION_MASK) == WINED3DFVF_XYZRHW ) || (FVF & (WINED3DFVF_DIFFUSE | WINED3DFVF_SPECULAR)); - if(!GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) { + if (!This->adapter->gl_info.supported[ARB_VERTEX_BUFFER_OBJECT]) + { TRACE("Not creating a vbo because GL_ARB_vertex_buffer is not supported\n"); } else if(Pool == WINED3DPOOL_SYSTEMMEM) { TRACE("Not creating a vbo because the vertex buffer is in system memory\n"); @@ -579,7 +581,9 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateIndexBuffer(IWineD3DDevice *iface TRACE("Created buffer %p.\n", object); - if(Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) && GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) { + if (Pool != WINED3DPOOL_SYSTEMMEM && !(Usage & WINED3DUSAGE_DYNAMIC) + && This->adapter->gl_info.supported[ARB_VERTEX_BUFFER_OBJECT]) + { object->flags |= WINED3D_BUFFER_CREATEBO; } @@ -817,6 +821,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateCubeTexture(IWineD3DDevice *iface static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINED3DQUERYTYPE Type, IWineD3DQuery **ppQuery, IUnknown* parent) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; IWineD3DQueryImpl *object; /*NOTE: impl ref allowed since this is a create function */ HRESULT hr = WINED3DERR_NOTAVAILABLE; const IWineD3DQueryVtbl *vtable; @@ -825,7 +830,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE switch(Type) { case WINED3DQUERYTYPE_OCCLUSION: TRACE("(%p) occlusion query\n", This); - if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (gl_info->supported[ARB_OCCLUSION_QUERY]) hr = WINED3D_OK; else WARN("Unsupported in local OpenGL implementation: ARB_OCCLUSION_QUERY/NV_OCCLUSION_QUERY\n"); @@ -834,7 +839,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_CreateQuery(IWineD3DDevice *iface, WINE break; case WINED3DQUERYTYPE_EVENT: - if(!(GL_SUPPORT(NV_FENCE) || GL_SUPPORT(APPLE_FENCE) )) { + if (!gl_info->supported[NV_FENCE] && !gl_info->supported[APPLE_FENCE]) + { /* Half-Life 2 needs this query. It does not render the main menu correctly otherwise * Pretend to support it, faking this query does not do much harm except potentially lowering performance */ @@ -1683,7 +1689,9 @@ static void IWineD3DDeviceImpl_LoadLogo(IWineD3DDeviceImpl *This, const char *fi } /* Context activation is done by the caller. */ -static void create_dummy_textures(IWineD3DDeviceImpl *This) { +static void create_dummy_textures(IWineD3DDeviceImpl *This) +{ + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; unsigned int i; /* Under DirectX you can have texture stage operations even if no texture is bound, whereas opengl will only do texture operations when a valid texture is @@ -1692,13 +1700,14 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This) { then the default texture will kick in until replaced by a SetTexture call */ ENTER_GL(); - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { /* The dummy texture does not have client storage backing */ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)"); } - for (i = 0; i < This->adapter->gl_info.limits.textures; ++i) + for (i = 0; i < gl_info->limits.textures; ++i) { GLubyte white = 255; @@ -1719,7 +1728,9 @@ static void create_dummy_textures(IWineD3DDeviceImpl *This) { glTexImage2D(GL_TEXTURE_2D, 0, GL_LUMINANCE, 1, 1, 0, GL_LUMINANCE, GL_UNSIGNED_BYTE, &white); checkGLcall("glTexImage2D"); } - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { /* Reenable because if supported it is enabled by default */ glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)"); @@ -3734,6 +3745,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn const struct wined3d_stream_info *stream_info, struct wined3d_buffer *dest, DWORD dwFlags, DWORD DestFVF) { + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; char *dest_ptr, *dest_conv = NULL, *dest_conv_addr = NULL; unsigned int i; WINED3DVIEWPORT vp; @@ -3762,7 +3774,7 @@ static HRESULT process_vertices_strided(IWineD3DDeviceImpl *This, DWORD dwDestIn /* Get a pointer into the destination vbo(create one if none exists) and * write correct opengl data into it. It's cheap and allows us to run drawStridedFast */ - if (!dest->buffer_object && GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT)) + if (!dest->buffer_object && gl_info->supported[ARB_VERTEX_BUFFER_OBJECT]) { dest->flags |= WINED3D_BUFFER_CREATEBO; IWineD3DBuffer_PreLoad((IWineD3DBuffer *)dest); @@ -6331,8 +6343,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i This->cursorHeight = pSur->currentDesc.Height; if (SUCCEEDED(IWineD3DSurface_LockRect(pCursorBitmap, &rect, NULL, WINED3DLOCK_READONLY))) { - const struct GlPixelFormatDesc *glDesc = - getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, &This->adapter->gl_info); + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; + const struct GlPixelFormatDesc *glDesc = getFormatDescEntry(WINED3DFMT_B8G8R8A8_UNORM, gl_info); struct wined3d_context *context; char *mem, *bits = rect.pBits; GLint intfmt = glDesc->glInternal; @@ -6355,7 +6367,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i ENTER_GL(); - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_FALSE)"); } @@ -6378,7 +6391,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetCursorProperties(IWineD3DDevice* i HeapFree(GetProcessHeap(), 0, mem); checkGLcall("glTexImage2D"); - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE); checkGLcall("glPixelStorei(GL_UNPACK_CLIENT_STORAGE_APPLE, GL_TRUE)"); } @@ -6522,7 +6536,8 @@ static HRESULT WINAPI IWineD3DDeviceImpl_EvictManagedResources(IWineD3DDevice* static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT_PARAMETERS* pPresentationParameters) { - IWineD3DDeviceImpl *This = surface->resource.wineD3DDevice; /* for GL_SUPPORT */ + IWineD3DDeviceImpl *device = surface->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; /* Reallocate proper memory for the front and back buffer and adjust their sizes */ if(surface->Flags & SFLAG_DIBSECTION) { @@ -6537,8 +6552,9 @@ static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT } surface->currentDesc.Width = pPresentationParameters->BackBufferWidth; surface->currentDesc.Height = pPresentationParameters->BackBufferHeight; - if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || GL_SUPPORT(ARB_TEXTURE_RECTANGLE) || - GL_SUPPORT(WINE_NORMALIZED_TEXRECT)) { + if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[ARB_TEXTURE_RECTANGLE] + || gl_info->supported[WINE_NORMALIZED_TEXRECT]) + { surface->pow2Width = pPresentationParameters->BackBufferWidth; surface->pow2Height = pPresentationParameters->BackBufferHeight; } else { @@ -6553,7 +6569,7 @@ static void updateSurfaceDesc(IWineD3DSurfaceImpl *surface, const WINED3DPRESENT if (surface->texture_name) { - struct wined3d_context *context = context_acquire(This, NULL, CTXUSAGE_RESOURCELOAD); + struct wined3d_context *context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); ENTER_GL(); glDeleteTextures(1, &surface->texture_name); LEAVE_GL(); diff --git a/dlls/wined3d/directx.c b/dlls/wined3d/directx.c index 3551747fae1..80d4685224d 100644 --- a/dlls/wined3d/directx.c +++ b/dlls/wined3d/directx.c @@ -635,7 +635,7 @@ static BOOL match_allows_spec_alpha(const struct wined3d_gl_info *gl_info, const GLenum error; DWORD data[16]; - if(!GL_SUPPORT(EXT_SECONDARY_COLOR)) return FALSE; + if (!gl_info->supported[EXT_SECONDARY_COLOR]) return FALSE; ENTER_GL(); while(glGetError()); @@ -660,7 +660,7 @@ static BOOL match_apple_nvts(const struct wined3d_gl_info *gl_info, const char * enum wined3d_pci_vendor vendor, enum wined3d_pci_device device) { if (!match_apple(gl_info, gl_renderer, vendor, device)) return FALSE; - return GL_SUPPORT(NV_TEXTURE_SHADER); + return gl_info->supported[NV_TEXTURE_SHADER]; } /* A GL context is provided by the caller */ @@ -677,7 +677,7 @@ static BOOL match_broken_nv_clip(const struct wined3d_gl_info *gl_info, const ch "MOV result.position, 0.0;\n" "END\n"; - if(!GL_SUPPORT(NV_VERTEX_PROGRAM2_OPTION)) return FALSE; + if (!gl_info->supported[NV_VERTEX_PROGRAM2_OPTION]) return FALSE; ENTER_GL(); while(glGetError()); @@ -2838,7 +2838,8 @@ static BOOL CheckSrgbReadCapability(struct wined3d_adapter *adapter, const struc const struct wined3d_gl_info *gl_info = &adapter->gl_info; /* Check for supported sRGB formats (Texture loading and framebuffer) */ - if(!GL_SUPPORT(EXT_TEXTURE_SRGB)) { + if (!gl_info->supported[EXT_TEXTURE_SRGB]) + { TRACE_(d3d_caps)("[FAILED] GL_EXT_texture_sRGB not supported\n"); return FALSE; } @@ -3009,7 +3010,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, case WINED3DFMT_DXT3: case WINED3DFMT_DXT4: case WINED3DFMT_DXT5: - if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_S3TC)) { + if (gl_info->supported[EXT_TEXTURE_COMPRESSION_S3TC]) + { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } @@ -3039,7 +3041,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, /* YUV formats */ case WINED3DFMT_UYVY: case WINED3DFMT_YUY2: - if(GL_SUPPORT(APPLE_YCBCR_422)) { + if (gl_info->supported[APPLE_YCBCR_422]) + { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } @@ -3059,7 +3062,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, case WINED3DFMT_R16_FLOAT: case WINED3DFMT_R16G16_FLOAT: case WINED3DFMT_R16G16B16A16_FLOAT: - if(GL_SUPPORT(ARB_TEXTURE_FLOAT) && GL_SUPPORT(ARB_HALF_FLOAT_PIXEL)) { + if (gl_info->supported[ARB_TEXTURE_FLOAT] && gl_info->supported[ARB_HALF_FLOAT_PIXEL]) + { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } @@ -3069,7 +3073,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, case WINED3DFMT_R32_FLOAT: case WINED3DFMT_R32G32_FLOAT: case WINED3DFMT_R32G32B32A32_FLOAT: - if (GL_SUPPORT(ARB_TEXTURE_FLOAT)) { + if (gl_info->supported[ARB_TEXTURE_FLOAT]) + { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } @@ -3088,7 +3093,8 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, */ case WINEMAKEFOURCC('I','N','S','T'): TRACE("ATI Instancing check hack\n"); - if(GL_SUPPORT(ARB_VERTEX_PROGRAM) || GL_SUPPORT(ARB_VERTEX_SHADER)) { + if (gl_info->supported[ARB_VERTEX_PROGRAM] || gl_info->supported[ARB_VERTEX_SHADER]) + { TRACE_(d3d_caps)("[OK]\n"); return TRUE; } @@ -3104,7 +3110,9 @@ static BOOL CheckTextureCapability(struct wined3d_adapter *adapter, /* Vendor specific formats */ case WINED3DFMT_ATI2N: - if(GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC) || GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) { + if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC] + || gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) + { shader_backend = select_shader_backend(adapter, DeviceType); fp = select_fragment_implementation(adapter, DeviceType); if (shader_backend->shader_color_fixup_supported(format_desc->color_fixup) @@ -3206,7 +3214,8 @@ static BOOL CheckVertexTextureCapability(struct wined3d_adapter *adapter, const switch (format_desc->format) { case WINED3DFMT_R32G32B32A32_FLOAT: - if (!GL_SUPPORT(ARB_TEXTURE_FLOAT)) { + if (!gl_info->supported[ARB_TEXTURE_FLOAT]) + { TRACE_(d3d_caps)("[FAILED]\n"); return FALSE; } @@ -3260,13 +3269,15 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt * - D3DUSAGE_SOFTWAREPROCESSING * - D3DUSAGE_QUERY_WRAPANDMIP */ - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { /* Check if the texture format is around */ if (CheckTextureCapability(adapter, DeviceType, format_desc)) { if(Usage & WINED3DUSAGE_AUTOGENMIPMAP) { /* Check for automatic mipmap generation support */ - if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) { + if (gl_info->supported[SGIS_GENERATE_MIPMAP]) + { UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP; } else { /* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */ @@ -3432,7 +3443,8 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt { if(Usage & WINED3DUSAGE_AUTOGENMIPMAP) { /* Check for automatic mipmap generation support */ - if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) { + if (gl_info->supported[SGIS_GENERATE_MIPMAP]) + { UsageCaps |= WINED3DUSAGE_AUTOGENMIPMAP; } else { /* When autogenmipmap isn't around continue and return WINED3DOK_NOAUTOGEN instead of D3D_OK */ @@ -3565,7 +3577,8 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt } /* Check volume texture and volume usage caps */ - if(GL_SUPPORT(EXT_TEXTURE3D)) { + if (gl_info->supported[EXT_TEXTURE3D]) + { if (!CheckTextureCapability(adapter, DeviceType, format_desc)) { TRACE_(d3d_caps)("[FAILED] - Format not supported\n"); @@ -3669,14 +3682,16 @@ static HRESULT WINAPI IWineD3DImpl_CheckDeviceFormat(IWineD3D *iface, UINT Adapt case WINED3DFMT_R8G8B8A8_SNORM: case WINED3DFMT_R16G16_SNORM: - if(!GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (!gl_info->supported[NV_TEXTURE_SHADER]) + { TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n"); return WINED3DERR_NOTAVAILABLE; } break; case WINED3DFMT_R8G8_SNORM: - if(!GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (!gl_info->supported[NV_TEXTURE_SHADER]) + { TRACE_(d3d_caps)("[FAILED] - No converted formats on volumes\n"); return WINED3DERR_NOTAVAILABLE; } @@ -3756,15 +3771,25 @@ static const struct fragment_pipeline *select_fragment_implementation(struct win int ps_selected_mode; select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); - if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { return &arbfp_fragment_pipeline; - } else if(ps_selected_mode == SHADER_ATI) { + } + else if (ps_selected_mode == SHADER_ATI) + { return &atifs_fragment_pipeline; - } else if(GL_SUPPORT(NV_REGISTER_COMBINERS) && GL_SUPPORT(NV_TEXTURE_SHADER2)) { + } + else if (gl_info->supported[NV_REGISTER_COMBINERS] && gl_info->supported[NV_TEXTURE_SHADER2]) + { return &nvts_fragment_pipeline; - } else if(GL_SUPPORT(NV_REGISTER_COMBINERS)) { + } + else if (gl_info->supported[NV_REGISTER_COMBINERS]) + { return &nvrc_fragment_pipeline; - } else { + } + else + { return &ffp_fragment_pipeline; } } @@ -3776,9 +3801,13 @@ static const struct blit_shader *select_blit_implementation(struct wined3d_adapt int ps_selected_mode; select_shader_mode(&adapter->gl_info, &ps_selected_mode, &vs_selected_mode); - if((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + if ((ps_selected_mode == SHADER_ARB || ps_selected_mode == SHADER_GLSL) + && gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { return &arbfp_blit; - } else { + } + else + { return &ffp_blit; } } @@ -3817,7 +3846,8 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->Caps2 = WINED3DCAPS2_CANRENDERWINDOWED | WINED3DCAPS2_FULLSCREENGAMMA | WINED3DCAPS2_DYNAMICTEXTURES; - if(GL_SUPPORT(SGIS_GENERATE_MIPMAP)) { + if (gl_info->supported[SGIS_GENERATE_MIPMAP]) + { pCaps->Caps2 |= WINED3DCAPS2_CANAUTOGENMIPMAP; } @@ -3863,7 +3893,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPMISCCAPS_MRTINDEPENDENTBITDEPTHS WINED3DPMISCCAPS_FOGVERTEXCLAMPED */ - if(GL_SUPPORT(EXT_BLEND_EQUATION_SEPARATE) && GL_SUPPORT(EXT_BLEND_FUNC_SEPARATE)) + if (gl_info->supported[EXT_BLEND_EQUATION_SEPARATE] && gl_info->supported[EXT_BLEND_FUNC_SEPARATE]) pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_SEPARATEALPHABLEND; pCaps->RasterCaps = WINED3DPRASTERCAPS_DITHER | @@ -3879,12 +3909,14 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPRASTERCAPS_SLOPESCALEDEPTHBIAS | WINED3DPRASTERCAPS_DEPTHBIAS; - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) { + if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + { pCaps->RasterCaps |= WINED3DPRASTERCAPS_ANISOTROPY | WINED3DPRASTERCAPS_ZBIAS | WINED3DPRASTERCAPS_MIPMAPLODBIAS; } - if(GL_SUPPORT(NV_FOG_DISTANCE)) { + if (gl_info->supported[NV_FOG_DISTANCE]) + { pCaps->RasterCaps |= WINED3DPRASTERCAPS_FOGRANGE; } /* FIXME Add: @@ -3934,7 +3966,8 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, * legacy settings for srcblend only */ - if( GL_SUPPORT(EXT_BLEND_COLOR)) { + if (gl_info->supported[EXT_BLEND_COLOR]) + { pCaps->SrcBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR; pCaps->DestBlendCaps |= WINED3DPBLENDCAPS_BLENDFACTOR; } @@ -3966,18 +3999,21 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPTEXTURECAPS_PROJECTED | WINED3DPTEXTURECAPS_PERSPECTIVE; - if( !GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO)) { + if (!gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO]) + { pCaps->TextureCaps |= WINED3DPTEXTURECAPS_POW2 | WINED3DPTEXTURECAPS_NONPOW2CONDITIONAL; } - if( GL_SUPPORT(EXT_TEXTURE3D)) { + if (gl_info->supported[EXT_TEXTURE3D]) + { pCaps->TextureCaps |= WINED3DPTEXTURECAPS_VOLUMEMAP | WINED3DPTEXTURECAPS_MIPVOLUMEMAP | WINED3DPTEXTURECAPS_VOLUMEMAP_POW2; } - if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { pCaps->TextureCaps |= WINED3DPTEXTURECAPS_CUBEMAP | WINED3DPTEXTURECAPS_MIPCUBEMAP | WINED3DPTEXTURECAPS_CUBEMAP_POW2; @@ -3997,12 +4033,14 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPTFILTERCAPS_MIPNEAREST | WINED3DPTFILTERCAPS_NEAREST; - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) { + if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + { pCaps->TextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC | WINED3DPTFILTERCAPS_MINFANISOTROPIC; } - if (GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { pCaps->CubeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR | WINED3DPTFILTERCAPS_MAGFPOINT | WINED3DPTFILTERCAPS_MINFLINEAR | @@ -4016,14 +4054,16 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPTFILTERCAPS_MIPNEAREST | WINED3DPTFILTERCAPS_NEAREST; - if (GL_SUPPORT(EXT_TEXTURE_FILTER_ANISOTROPIC)) { + if (gl_info->supported[EXT_TEXTURE_FILTER_ANISOTROPIC]) + { pCaps->CubeTextureFilterCaps |= WINED3DPTFILTERCAPS_MAGFANISOTROPIC | WINED3DPTFILTERCAPS_MINFANISOTROPIC; } } else pCaps->CubeTextureFilterCaps = 0; - if (GL_SUPPORT(EXT_TEXTURE3D)) { + if (gl_info->supported[EXT_TEXTURE3D]) + { pCaps->VolumeTextureFilterCaps = WINED3DPTFILTERCAPS_MAGFLINEAR | WINED3DPTFILTERCAPS_MAGFPOINT | WINED3DPTFILTERCAPS_MINFLINEAR | @@ -4043,27 +4083,34 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DPTADDRESSCAPS_CLAMP | WINED3DPTADDRESSCAPS_WRAP; - if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) { + if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP]) + { pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER; } - if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) { + if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT]) + { pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR; } - if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) { + if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE]) + { pCaps->TextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE; } - if (GL_SUPPORT(EXT_TEXTURE3D)) { + if (gl_info->supported[EXT_TEXTURE3D]) + { pCaps->VolumeTextureAddressCaps = WINED3DPTADDRESSCAPS_INDEPENDENTUV | WINED3DPTADDRESSCAPS_CLAMP | WINED3DPTADDRESSCAPS_WRAP; - if (GL_SUPPORT(ARB_TEXTURE_BORDER_CLAMP)) { + if (gl_info->supported[ARB_TEXTURE_BORDER_CLAMP]) + { pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_BORDER; } - if (GL_SUPPORT(ARB_TEXTURE_MIRRORED_REPEAT)) { + if (gl_info->supported[ARB_TEXTURE_MIRRORED_REPEAT]) + { pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRROR; } - if (GL_SUPPORT(ATI_TEXTURE_MIRROR_ONCE)) { + if (gl_info->supported[ATI_TEXTURE_MIRROR_ONCE]) + { pCaps->VolumeTextureAddressCaps |= WINED3DPTADDRESSCAPS_MIRRORONCE; } } else @@ -4081,7 +4128,7 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, pCaps->MaxTextureWidth = gl_info->limits.texture_size; pCaps->MaxTextureHeight = gl_info->limits.texture_size; - if (GL_SUPPORT(EXT_TEXTURE3D)) + if (gl_info->supported[EXT_TEXTURE3D]) pCaps->MaxVolumeExtent = gl_info->limits.texture3d_size; else pCaps->MaxVolumeExtent = 0; @@ -4103,11 +4150,13 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DSTENCILCAPS_KEEP | WINED3DSTENCILCAPS_REPLACE | WINED3DSTENCILCAPS_ZERO; - if (GL_SUPPORT(EXT_STENCIL_WRAP)) { + if (gl_info->supported[EXT_STENCIL_WRAP]) + { pCaps->StencilCaps |= WINED3DSTENCILCAPS_DECR | WINED3DSTENCILCAPS_INCR; } - if (GL_SUPPORT(EXT_STENCIL_TWO_SIDE) || GL_SUPPORT(ATI_SEPARATE_STENCIL)) { + if (gl_info->supported[EXT_STENCIL_TWO_SIDE] || gl_info->supported[ATI_SEPARATE_STENCIL]) + { pCaps->StencilCaps |= WINED3DSTENCILCAPS_TWOSIDED; } @@ -4282,7 +4331,8 @@ static HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3DDTCAPS_UBYTE4N | WINED3DDTCAPS_SHORT2N | WINED3DDTCAPS_SHORT4N; - if (GL_SUPPORT(ARB_HALF_FLOAT_VERTEX)) { + if (gl_info->supported[ARB_HALF_FLOAT_VERTEX]) + { pCaps->DeclTypes |= WINED3DDTCAPS_FLOAT16_2 | WINED3DDTCAPS_FLOAT16_4; } @@ -4585,16 +4635,22 @@ static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info) /* No 4 component entry points here */ specular_funcs[WINED3D_FFP_EMIT_FLOAT1] = invalid_func; specular_funcs[WINED3D_FFP_EMIT_FLOAT2] = invalid_func; - if(GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (gl_info->supported[EXT_SECONDARY_COLOR]) + { specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = (glAttribFunc)GL_EXTCALL(glSecondaryColor3fvEXT); - } else { + } + else + { specular_funcs[WINED3D_FFP_EMIT_FLOAT3] = warn_no_specular_func; } specular_funcs[WINED3D_FFP_EMIT_FLOAT4] = invalid_func; - if(GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (gl_info->supported[EXT_SECONDARY_COLOR]) + { specular_func_3ubv = (glAttribFunc)GL_EXTCALL(glSecondaryColor3ubvEXT); specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = specular_d3dcolor; - } else { + } + else + { specular_funcs[WINED3D_FFP_EMIT_D3DCOLOR] = warn_no_specular_func; } specular_funcs[WINED3D_FFP_EMIT_UBYTE4] = invalid_func; @@ -4646,7 +4702,7 @@ static void fillGLAttribFuncs(const struct wined3d_gl_info *gl_info) multi_texcoord_funcs[WINED3D_FFP_EMIT_USHORT4N] = invalid_texcoord_func; multi_texcoord_funcs[WINED3D_FFP_EMIT_UDEC3] = invalid_texcoord_func; multi_texcoord_funcs[WINED3D_FFP_EMIT_DEC3N] = invalid_texcoord_func; - if (GL_SUPPORT(NV_HALF_FLOAT)) + if (gl_info->supported[NV_HALF_FLOAT]) { /* Not supported by ARB_HALF_FLOAT_VERTEX, so check for NV_HALF_FLOAT */ multi_texcoord_funcs[WINED3D_FFP_EMIT_FLOAT16_2] = (glMultiTexCoordFunc)GL_EXTCALL(glMultiTexCoord2hvNV); @@ -4764,7 +4820,7 @@ BOOL InitAdapters(IWineD3DImpl *This) TRACE("DeviceName: %s\n", debugstr_w(DisplayDevice.DeviceName)); strcpyW(adapter->DeviceName, DisplayDevice.DeviceName); - if(GL_SUPPORT(WGL_ARB_PIXEL_FORMAT)) + if (gl_info->supported[WGL_ARB_PIXEL_FORMAT]) { int attribute; int attribs[10]; @@ -4808,8 +4864,10 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->auxBuffers = values[9]; cfgs->pbufferDrawable = FALSE; - /* Check for pbuffer support when it is around as wglGetPixelFormatAttribiv fails for unknown attributes. */ - if(GL_SUPPORT(WGL_ARB_PBUFFER)) { + /* Check for pbuffer support when it is around as + * wglGetPixelFormatAttribiv fails for unknown attributes. */ + if (gl_info->supported[WGL_ARB_PBUFFER]) + { int attrib = WGL_DRAW_TO_PBUFFER_ARB; int value; if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 1, &attrib, &value))) @@ -4818,7 +4876,8 @@ BOOL InitAdapters(IWineD3DImpl *This) cfgs->numSamples = 0; /* Check multisample support */ - if(GL_SUPPORT(ARB_MULTISAMPLE)) { + if (gl_info->supported[ARB_MULTISAMPLE]) + { int attrib[2] = {WGL_SAMPLE_BUFFERS_ARB, WGL_SAMPLES_ARB}; int value[2]; if(GL_EXTCALL(wglGetPixelFormatAttribivARB(hdc, iPixelFormat, 0, 2, attrib, value))) { diff --git a/dlls/wined3d/drawprim.c b/dlls/wined3d/drawprim.c index a9e69d12c4f..2d3051068ae 100644 --- a/dlls/wined3d/drawprim.c +++ b/dlls/wined3d/drawprim.c @@ -76,9 +76,10 @@ 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 = context->gl_info->limits.texture_stages; const BYTE *texCoords[WINED3DDP_MAXTEXCOORD]; const BYTE *diffuse = NULL, *specular = NULL, *normal = NULL, *position = NULL; + const struct wined3d_gl_info *gl_info = context->gl_info; + UINT texture_stages = gl_info->limits.texture_stages; const struct wined3d_stream_info_element *element; UINT num_untracked_materials; DWORD tex_mask = 0; @@ -147,7 +148,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context || si->elements[WINED3D_FFP_POSITION].format_desc->format == WINED3DFMT_R32G32B32A32_FLOAT) && This->stateBlock->renderState[WINED3DRS_FOGTABLEMODE] == WINED3DFOG_NONE) { - if (GL_SUPPORT(EXT_FOG_COORD)) + if (gl_info->supported[EXT_FOG_COORD]) { if (element->format_desc->format == WINED3DFMT_B8G8R8A8_UNORM) specular_fog = TRUE; else FIXME("Implement fog coordinates from %s\n", debug_d3dformat(element->format_desc->format)); @@ -165,7 +166,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context } } } - else if (GL_SUPPORT(EXT_SECONDARY_COLOR)) + else if (gl_info->supported[EXT_SECONDARY_COLOR]) { GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0); } @@ -175,7 +176,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context int coordIdx = This->stateBlock->textureState[textureNo][WINED3DTSS_TEXCOORDINDEX]; DWORD texture_idx = This->texUnitMap[textureNo]; - if (!GL_SUPPORT(ARB_MULTITEXTURE) && textureNo > 0) + if (!gl_info->supported[ARB_MULTITEXTURE] && textureNo > 0) { FIXME("Program using multiple concurrent textures which this opengl implementation doesn't support\n"); continue; @@ -205,7 +206,7 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context else { TRACE("tex: %d - Skipping tex coords, as no data supplied\n", textureNo); - if (GL_SUPPORT(ARB_MULTITEXTURE)) + if (gl_info->supported[ARB_MULTITEXTURE]) GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + texture_idx, 0, 0, 0, 1)); else glTexCoord4f(0, 0, 0, 1); @@ -314,6 +315,8 @@ static void drawStridedSlow(IWineD3DDevice *iface, const struct wined3d_context /* GL locking is done by the caller */ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format, const UINT index, const void *ptr) { + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; + switch(format) { case WINED3DFMT_R32_FLOAT: @@ -333,7 +336,7 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format GL_EXTCALL(glVertexAttrib4ubvARB(index, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA)) + if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) { const DWORD *src = ptr; DWORD c = *src & 0xff00ff00; @@ -386,20 +389,26 @@ static inline void send_attribute(IWineD3DDeviceImpl *This, WINED3DFORMAT format /* Are those 16 bit floats. C doesn't have a 16 bit float type. I could read the single bits and calculate a 4 * byte float according to the IEEE standard */ - if (GL_SUPPORT(NV_HALF_FLOAT)) { + if (gl_info->supported[NV_HALF_FLOAT]) + { /* Not supported by GL_ARB_half_float_vertex */ GL_EXTCALL(glVertexAttrib2hvNV(index, ptr)); - } else { + } + else + { float x = float_16_to_32(((const unsigned short *)ptr) + 0); float y = float_16_to_32(((const unsigned short *)ptr) + 1); GL_EXTCALL(glVertexAttrib2fARB(index, x, y)); } break; case WINED3DFMT_R16G16B16A16_FLOAT: - if (GL_SUPPORT(NV_HALF_FLOAT)) { + if (gl_info->supported[NV_HALF_FLOAT]) + { /* Not supported by GL_ARB_half_float_vertex */ GL_EXTCALL(glVertexAttrib4hvNV(index, ptr)); - } else { + } + else + { float x = float_16_to_32(((const unsigned short *)ptr) + 0); float y = float_16_to_32(((const unsigned short *)ptr) + 1); float z = float_16_to_32(((const unsigned short *)ptr) + 2); diff --git a/dlls/wined3d/gl_compat.c b/dlls/wined3d/gl_compat.c index 9166041d7dc..0f8eaba83d2 100644 --- a/dlls/wined3d/gl_compat.c +++ b/dlls/wined3d/gl_compat.c @@ -342,10 +342,10 @@ static void WINE_GLAPI wine_glFogCoorddvEXT(const GLdouble *f) { /* End GL_EXT_fog_coord emulation */ -#define GLINFO_LOCATION (*gl_info) void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) { - if(!GL_SUPPORT(ARB_MULTITEXTURE)) { + if (!gl_info->supported[ARB_MULTITEXTURE]) + { TRACE("Applying GL_ARB_multitexture emulation hooks\n"); gl_info->glActiveTextureARB = wine_glActiveTextureARB; gl_info->glClientActiveTextureARB = wine_glClientActiveTextureARB; @@ -380,7 +380,8 @@ void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) gl_info->supported[ARB_MULTITEXTURE] = TRUE; } - if(!GL_SUPPORT(EXT_FOG_COORD)) { + if (!gl_info->supported[EXT_FOG_COORD]) + { /* This emulation isn't perfect. There are a number of potential problems, but they should * not matter in practise: * @@ -405,10 +406,13 @@ void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) * it via the GL core version, or someone messed around in the extension table in directx.c. Add version- * dependent loading for this extension if we ever hit this situation */ - if(GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + if (gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { FIXME("GL implementation supports GL_ARB_fragment_program but not GL_EXT_fog_coord\n"); FIXME("The fog coord emulation will most likely fail\n"); - } else if(GL_SUPPORT(ARB_FRAGMENT_SHADER)) { + } + else if (gl_info->supported[ARB_FRAGMENT_SHADER]) + { FIXME("GL implementation supports GL_ARB_fragment_shader but not GL_EXT_fog_coord\n"); FIXME("The fog coord emulation will most likely fail\n"); } @@ -533,4 +537,3 @@ void add_gl_compat_wrappers(struct wined3d_gl_info *gl_info) gl_info->supported[EXT_FOG_COORD] = TRUE; } } -#undef GLINFO_LOCATION diff --git a/dlls/wined3d/glsl_shader.c b/dlls/wined3d/glsl_shader.c index b97936da3a4..995fbcc1cf7 100644 --- a/dlls/wined3d/glsl_shader.c +++ b/dlls/wined3d/glsl_shader.c @@ -2766,7 +2766,8 @@ static void shader_glsl_texldd(const struct wined3d_shader_instruction *ins) DWORD sampler_idx; DWORD swizzle = ins->src[1].swizzle; - if(!GL_SUPPORT(ARB_SHADER_TEXTURE_LOD)) { + if (!gl_info->supported[ARB_SHADER_TEXTURE_LOD]) + { FIXME("texldd used, but not supported by hardware. Falling back to regular tex\n"); return shader_glsl_tex(ins); } @@ -3743,10 +3744,12 @@ static GLuint shader_glsl_generate_pshader(const struct wined3d_context *context shader_addline(buffer, "#version 120\n"); - if(GL_SUPPORT(ARB_SHADER_TEXTURE_LOD) && reg_maps->usestexldd) { + if (gl_info->supported[ARB_SHADER_TEXTURE_LOD] && reg_maps->usestexldd) + { shader_addline(buffer, "#extension GL_ARB_shader_texture_lod : enable\n"); } - if (GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { /* The spec says that it doesn't have to be explicitly enabled, but the nvidia * drivers write a warning if we don't do so */ @@ -4318,11 +4321,15 @@ static void shader_glsl_select(const struct wined3d_context *context, BOOL usePS current_vertex_color_clamp = priv->glsl_program ? priv->glsl_program->vertex_color_clamp : GL_FIXED_ONLY_ARB; - if (old_vertex_color_clamp != current_vertex_color_clamp) { - if (GL_SUPPORT(ARB_COLOR_BUFFER_FLOAT)) { + if (old_vertex_color_clamp != current_vertex_color_clamp) + { + if (gl_info->supported[ARB_COLOR_BUFFER_FLOAT]) + { GL_EXTCALL(glClampColorARB(GL_CLAMP_VERTEX_COLOR_ARB, current_vertex_color_clamp)); checkGLcall("glClampColorARB"); - } else { + } + else + { FIXME("vertex color clamp needs to be changed, but extension not supported.\n"); } } diff --git a/dlls/wined3d/nvidia_texture_shader.c b/dlls/wined3d/nvidia_texture_shader.c index 3f8c31ccad0..627bd68293f 100644 --- a/dlls/wined3d/nvidia_texture_shader.c +++ b/dlls/wined3d/nvidia_texture_shader.c @@ -132,6 +132,7 @@ static void get_src_and_opr_nvrc(DWORD stage, DWORD arg, BOOL is_alpha, GLenum* void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3, INT texture_idx, DWORD dst) { IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl*)iface; + const struct wined3d_gl_info *gl_info = &This->adapter->gl_info; tex_op_args tex_op_args = {{0}, {0}, {0}}; GLenum portion = is_alpha ? GL_ALPHA : GL_RGB; GLenum target = GL_COMBINER0_NV + stage; @@ -428,7 +429,8 @@ void set_tex_op_nvrc(IWineD3DDevice *iface, BOOL is_alpha, int stage, WINED3DTEX case WINED3DTOP_BUMPENVMAPLUMINANCE: case WINED3DTOP_BUMPENVMAP: - if(GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (gl_info->supported[NV_TEXTURE_SHADER]) + { /* The bump map stage itself isn't exciting, just read the texture. But tell the next stage to * perform bump mapping and source from the current stage. Pretty much a SELECTARG2. * ARG2 is passed through unmodified(apps will most likely use D3DTA_CURRENT for arg2, arg1 @@ -493,11 +495,13 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct checkGLcall("glDisable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } @@ -513,11 +517,16 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct /* The sampler will also activate the correct texture dimensions, so no need to do it here * if the sampler for this stage is dirty */ - if(!isStateDirty(context, STATE_SAMPLER(stage))) { - if (tex_used) { - if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + if (!isStateDirty(context, STATE_SAMPLER(stage))) + { + if (tex_used) + { + if (gl_info->supported[NV_TEXTURE_SHADER2]) + { nvts_activate_dimensions(stage, stateblock, context); - } else { + } + else + { texture_activate_dimensions(stage, stateblock, context); } } @@ -535,7 +544,8 @@ static void nvrc_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct /* In register combiners bump mapping is done in the stage AFTER the one that has the bump map operation set, * thus the texture shader may have to be updated */ - if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + if (gl_info->supported[NV_TEXTURE_SHADER2]) + { BOOL usesBump = (stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAPLUMINANCE || stateblock->textureState[stage][WINED3DTSS_COLOROP] == WINED3DTOP_BUMPENVMAP) ? TRUE : FALSE; BOOL usedBump = (context->texShaderBumpMap & 1 << (stage + 1)) ? TRUE : FALSE; @@ -600,9 +610,7 @@ static void nvrc_texfactor(DWORD state, IWineD3DStateBlockImpl *stateblock, stru D3DCOLORTOGLFLOAT4(stateblock->renderState[WINED3DRS_TEXTUREFACTOR], col); GL_EXTCALL(glCombinerParameterfvNV(GL_CONSTANT_COLOR0_NV, &col[0])); } -#undef GLINFO_LOCATION -#define GLINFO_LOCATION (*gl_info) /* Context activation is done by the caller. */ static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { } @@ -646,7 +654,8 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR | WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA; - if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + if (gl_info->supported[NV_TEXTURE_SHADER2]) + { /* Bump mapping is supported already in NV_TEXTURE_SHADER, but that extension does * not support 3D textures. This asks for trouble if an app uses both bump mapping * and 3D textures. It also allows us to keep the code simpler by having texture @@ -669,7 +678,7 @@ static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, /* The caps below can be supported but aren't handled yet in utils.c 'd3dta_to_combiner_input', disable them until support is fixed */ #if 0 - if (GL_SUPPORT(NV_REGISTER_COMBINERS2)) + if (gl_info->supported[NV_REGISTER_COMBINERS2]) pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_PERSTAGECONSTANT; #endif } diff --git a/dlls/wined3d/query.c b/dlls/wined3d/query.c index 1db6e7a5c91..76f519dd04f 100644 --- a/dlls/wined3d/query.c +++ b/dlls/wined3d/query.c @@ -272,6 +272,8 @@ static HRESULT WINAPI IWineD3DQueryImpl_GetData(IWineD3DQuery* iface, void* pDa static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, void* pData, DWORD dwSize, DWORD dwGetDataFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *) iface; struct wined3d_occlusion_query *query = This->extendedData; + IWineD3DDeviceImpl *device = This->wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; struct wined3d_context *context; DWORD* data = pData; GLuint available; @@ -297,7 +299,7 @@ static HRESULT WINAPI IWineD3DOcclusionQueryImpl_GetData(IWineD3DQuery* iface, return S_FALSE; } - if (!GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (!gl_info->supported[ARB_OCCLUSION_QUERY]) { WARN("(%p) : Occlusion queries not supported. Returning 1.\n", This); *data = 1; @@ -373,12 +375,12 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_GetData(IWineD3DQuery* iface, void ENTER_GL(); - if (GL_SUPPORT(APPLE_FENCE)) + if (context->gl_info->supported[APPLE_FENCE]) { *data = GL_EXTCALL(glTestFenceAPPLE(query->id)); checkGLcall("glTestFenceAPPLE"); } - else if (GL_SUPPORT(NV_FENCE)) + else if (context->gl_info->supported[NV_FENCE]) { *data = GL_EXTCALL(glTestFenceNV(query->id)); checkGLcall("glTestFenceNV"); @@ -495,12 +497,12 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD ENTER_GL(); - if (GL_SUPPORT(APPLE_FENCE)) + if (context->gl_info->supported[APPLE_FENCE]) { GL_EXTCALL(glSetFenceAPPLE(query->id)); checkGLcall("glSetFenceAPPLE"); } - else if (GL_SUPPORT(NV_FENCE)) + else if (context->gl_info->supported[NV_FENCE]) { GL_EXTCALL(glSetFenceNV(query->id, GL_ALL_COMPLETED_NV)); checkGLcall("glSetFenceNV"); @@ -527,8 +529,10 @@ static HRESULT WINAPI IWineD3DEventQueryImpl_Issue(IWineD3DQuery* iface, DWORD static HRESULT WINAPI IWineD3DOcclusionQueryImpl_Issue(IWineD3DQuery* iface, DWORD dwIssueFlags) { IWineD3DQueryImpl *This = (IWineD3DQueryImpl *)iface; + IWineD3DDeviceImpl *device = This->wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; - if (GL_SUPPORT(ARB_OCCLUSION_QUERY)) + if (gl_info->supported[ARB_OCCLUSION_QUERY]) { struct wined3d_occlusion_query *query = This->extendedData; struct wined3d_context *context; diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c index 5cd29dba542..e7b64d99379 100644 --- a/dlls/wined3d/state.c +++ b/dlls/wined3d/state.c @@ -371,7 +371,8 @@ static void state_blend(DWORD state, IWineD3DStateBlockImpl *stateblock, struct int dstBlendAlpha = GL_ZERO; /* Separate alpha blending requires GL_EXT_blend_function_separate, so make sure it is around */ - if(!GL_SUPPORT(EXT_BLEND_FUNC_SEPARATE)) { + if (!context->gl_info->supported[EXT_BLEND_FUNC_SEPARATE]) + { WARN("Unsupported in local OpenGL implementation: glBlendFuncSeparateEXT\n"); return; } @@ -565,7 +566,7 @@ static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, stru if (stateblock->renderState[WINED3DRS_CLIPPING]) { enable = stateblock->renderState[WINED3DRS_CLIPPLANEENABLE]; disable = ~stateblock->renderState[WINED3DRS_CLIPPLANEENABLE]; - if (GL_SUPPORT(ARB_DEPTH_CLAMP)) + if (context->gl_info->supported[ARB_DEPTH_CLAMP]) { glDisable(GL_DEPTH_CLAMP); checkGLcall("glDisable(GL_DEPTH_CLAMP)"); @@ -573,7 +574,7 @@ static void state_clipping(DWORD state, IWineD3DStateBlockImpl *stateblock, stru } else { disable = 0xffffffff; enable = 0x00; - if (GL_SUPPORT(ARB_DEPTH_CLAMP)) + if (context->gl_info->supported[ARB_DEPTH_CLAMP]) { glEnable(GL_DEPTH_CLAMP); checkGLcall("glEnable(GL_DEPTH_CLAMP)"); @@ -615,7 +616,9 @@ static void state_blendop(DWORD state, IWineD3DStateBlockImpl *stateblock, struc int blendEquationAlpha = GL_FUNC_ADD; /* BLENDOPALPHA requires GL_EXT_blend_equation_separate, so make sure it is around */ - if(stateblock->renderState[WINED3DRS_BLENDOPALPHA] && !GL_SUPPORT(EXT_BLEND_EQUATION_SEPARATE)) { + if (stateblock->renderState[WINED3DRS_BLENDOPALPHA] + && !context->gl_info->supported[EXT_BLEND_EQUATION_SEPARATE]) + { WARN("Unsupported in local OpenGL implementation: glBlendEquationSeparateEXT\n"); return; } @@ -704,14 +707,18 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock } checkGLcall("glMaterialf(GL_SHININESS)"); - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (context->gl_info->supported[EXT_SECONDARY_COLOR]) + { glEnable(GL_COLOR_SUM_EXT); - } else { + } + else + { TRACE("Specular colors cannot be enabled in this version of opengl\n"); } checkGLcall("glEnable(GL_COLOR_SUM)"); - if (GL_SUPPORT(NV_REGISTER_COMBINERS)) { + if (context->gl_info->supported[NV_REGISTER_COMBINERS]) + { GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_PLUS_SECONDARY_COLOR_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB)); checkGLcall("glFinalCombinerInputNV()"); } @@ -723,14 +730,18 @@ static void state_specularenable(DWORD state, IWineD3DStateBlockImpl *stateblock checkGLcall("glMaterialfv"); /* for the case of disabled lighting: */ - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (context->gl_info->supported[EXT_SECONDARY_COLOR]) + { glDisable(GL_COLOR_SUM_EXT); - } else { + } + else + { TRACE("Specular colors cannot be disabled in this version of opengl\n"); } checkGLcall("glDisable(GL_COLOR_SUM)"); - if (GL_SUPPORT(NV_REGISTER_COMBINERS)) { + if (context->gl_info->supported[NV_REGISTER_COMBINERS]) + { GL_EXTCALL(glFinalCombinerInputNV(GL_VARIABLE_B_NV, GL_SPARE0_NV, GL_UNSIGNED_IDENTITY_NV, GL_RGB)); checkGLcall("glFinalCombinerInputNV()"); } @@ -838,7 +849,8 @@ static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struc glEnable(GL_STENCIL_TEST); checkGLcall("glEnable GL_STENCIL_TEST"); - if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) { + if (context->gl_info->supported[EXT_STENCIL_TWO_SIDE]) + { /* Apply back first, then front. This function calls glActiveStencilFaceEXT, * which has an effect on the code below too. If we apply the front face * afterwards, we are sure that the active stencil face is set to front, @@ -849,7 +861,9 @@ static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struc func_ccw, ref, mask, stencilFail_ccw, depthFail_ccw, stencilPass_ccw); renderstate_stencil_twosided(context, GL_FRONT, func, ref, mask, stencilFail, depthFail, stencilPass); - } else if(GL_SUPPORT(ATI_SEPARATE_STENCIL)) { + } + else if (context->gl_info->supported[ATI_SEPARATE_STENCIL]) + { GL_EXTCALL(glStencilFuncSeparateATI(func, func_ccw, ref, mask)); checkGLcall("glStencilFuncSeparateATI(...)"); GL_EXTCALL(glStencilOpSeparateATI(GL_FRONT, stencilFail, depthFail, stencilPass)); @@ -859,8 +873,11 @@ static void state_stencil(DWORD state, IWineD3DStateBlockImpl *stateblock, struc } else { ERR("Separate (two sided) stencil not supported on this version of opengl. Caps weren't honored?\n"); } - } else if(onesided_enable) { - if(GL_SUPPORT(EXT_STENCIL_TWO_SIDE)) { + } + else if(onesided_enable) + { + if (context->gl_info->supported[EXT_STENCIL_TWO_SIDE]) + { glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT); checkGLcall("glDisable(GL_STENCIL_TEST_TWO_SIDE_EXT)"); } @@ -1481,11 +1498,13 @@ static void state_pscale(DWORD state, IWineD3DStateBlockImpl *stateblock, struct att[2] = C.f / scaleFactor; } - if(GL_SUPPORT(ARB_POINT_PARAMETERS)) { + if (context->gl_info->supported[ARB_POINT_PARAMETERS]) + { GL_EXTCALL(glPointParameterfvARB)(GL_POINT_DISTANCE_ATTENUATION_ARB, att); checkGLcall("glPointParameterfvARB(GL_DISTANCE_ATTENUATION_ARB, ...)"); } - else if(GL_SUPPORT(EXT_POINT_PARAMETERS)) { + else if (context->gl_info->supported[EXT_POINT_PARAMETERS]) + { GL_EXTCALL(glPointParameterfvEXT)(GL_DISTANCE_ATTENUATION_EXT, att); checkGLcall("glPointParameterfvEXT(GL_DISTANCE_ATTENUATION_EXT, ...)"); } else if(stateblock->renderState[WINED3DRS_POINTSCALEENABLE]) { @@ -1981,7 +2000,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = TRUE; /* Assume will be handled */ /* Other texture operations require special extensions: */ - if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) { + if (context->gl_info->supported[NV_TEXTURE_ENV_COMBINE4]) + { if (isAlpha) { opr = GL_SRC_ALPHA; invopr = GL_ONE_MINUS_SRC_ALPHA; @@ -2566,7 +2586,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if checkGLcall("GL_TEXTURE_ENV, scal_target, 2"); break; case WINED3DTOP_SUBTRACT: - if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE)) { + if (context->gl_info->supported[ARB_TEXTURE_ENV_COMBINE]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_SUBTRACT); checkGLcall("GL_TEXTURE_ENV, comb_target, useext(GL_SUBTRACT)"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2657,10 +2678,13 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if checkGLcall("GL_TEXTURE_ENV, scal_target, 1"); break; case WINED3DTOP_DOTPRODUCT3: - if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3)) { + if (context->gl_info->supported[ARB_TEXTURE_ENV_DOT3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_ARB"); - } else if (GL_SUPPORT(EXT_TEXTURE_ENV_DOT3)) { + } + else if (context->gl_info->supported[EXT_TEXTURE_ENV_DOT3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_DOT3_RGBA_EXT"); } else { @@ -2696,7 +2720,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if checkGLcall("GL_TEXTURE_ENV, scal_target, 1"); break; case WINED3DTOP_ADDSMOOTH: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2723,7 +2748,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_BLENDTEXTUREALPHAPM: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, GL_TEXTURE); @@ -2744,7 +2770,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_MODULATEALPHA_ADDCOLOR: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2771,7 +2798,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_MODULATECOLOR_ADDALPHA: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2798,7 +2826,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_MODULATEINVALPHA_ADDCOLOR: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2825,7 +2854,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_MODULATEINVCOLOR_ADDALPHA: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2858,7 +2888,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if Handled = FALSE; break; case WINED3DTOP_MULTIPLYADD: - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3)) { + if (context->gl_info->supported[ATI_TEXTURE_ENV_COMBINE3]) + { glTexEnvi(GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI); checkGLcall("GL_TEXTURE_ENV, comb_target, GL_MODULATE_ADD_ATI"); glTexEnvi(GL_TEXTURE_ENV, src0_target, src1); @@ -2880,7 +2911,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if break; case WINED3DTOP_BUMPENVMAPLUMINANCE: case WINED3DTOP_BUMPENVMAP: - if(GL_SUPPORT(NV_TEXTURE_SHADER2)) { + if (context->gl_info->supported[NV_TEXTURE_SHADER2]) + { /* Technically texture shader support without register combiners is possible, but not expected to occur * on real world cards, so for now a fixme should be enough */ @@ -2892,7 +2924,8 @@ static void set_tex_op(const struct wined3d_context *context, IWineD3DDevice *if if (Handled) { BOOL combineOK = TRUE; - if (GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) { + if (context->gl_info->supported[NV_TEXTURE_ENV_COMBINE4]) + { DWORD op2; if (isAlpha) { @@ -2971,11 +3004,13 @@ static void tex_colorop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct checkGLcall("glDisable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (context->gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (context->gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } @@ -3088,7 +3123,8 @@ void tex_alphaop(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wined3d * this if block here, and the other code(color keying, texture unit selection) are the same */ TRACE("Setting alpha op for stage %d\n", stage); - if (GL_SUPPORT(NV_REGISTER_COMBINERS)) { + if (context->gl_info->supported[NV_REGISTER_COMBINERS]) + { set_tex_op_nvrc((IWineD3DDevice *)stateblock->wineD3DDevice, TRUE, stage, op, arg1, arg2, arg0, mapped_stage, @@ -3193,7 +3229,7 @@ static void loadTexCoords(const struct wined3d_context *context, IWineD3DStateBl GL_EXTCALL(glMultiTexCoord4fARB(GL_TEXTURE0_ARB + mapped_stage, 0, 0, 0, 1)); } } - if (GL_SUPPORT(NV_REGISTER_COMBINERS)) + if (context->gl_info->supported[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 < context->gl_info->limits.textures; ++textureNo) @@ -3279,7 +3315,7 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru case WINED3DTSS_TCI_CAMERASPACENORMAL: /* Note that NV_TEXGEN_REFLECTION support is implied when * ARB_TEXTURE_CUBE_MAP is supported */ - if (!GL_SUPPORT(NV_TEXGEN_REFLECTION)) + if (!context->gl_info->supported[NV_TEXGEN_REFLECTION]) { FIXME("WINED3DTSS_TCI_CAMERASPACENORMAL not supported.\n"); break; @@ -3310,7 +3346,7 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru case WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR: /* Note that NV_TEXGEN_REFLECTION support is implied when * ARB_TEXTURE_CUBE_MAP is supported */ - if (!GL_SUPPORT(NV_TEXGEN_REFLECTION)) + if (!context->gl_info->supported[NV_TEXGEN_REFLECTION]) { FIXME("WINED3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR not supported.\n"); break; @@ -3373,7 +3409,7 @@ static void tex_coordindex(DWORD state, IWineD3DStateBlockImpl *stateblock, stru * and do all the things linked to it * TODO: Tidy that up to reload only the arrays of the changed unit */ - GLuint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? ~0U : 0; + GLuint curVBO = context->gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0; unloadTexCoords(context); loadTexCoords(context, stateblock, &stateblock->wineD3DDevice->strided_streams, &curVBO); @@ -3475,7 +3511,8 @@ static void sampler(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wine basetexture_apply_state_changes(stateblock->textures[sampler], stateblock->textureState[sampler], stateblock->samplerState[sampler]); - if (GL_SUPPORT(EXT_TEXTURE_LOD_BIAS)) { + if (context->gl_info->supported[EXT_TEXTURE_LOD_BIAS]) + { tmpvalue.d = stateblock->samplerState[sampler][WINED3DSAMP_MIPMAPLODBIAS]; glTexEnvf(GL_TEXTURE_FILTER_CONTROL_EXT, GL_TEXTURE_LOD_BIAS_EXT, @@ -3949,7 +3986,6 @@ static void transform_projection(DWORD state, IWineD3DStateBlockImpl *stateblock } /* This should match any arrays loaded in loadVertexData. - * stateblock impl is required for GL_SUPPORT * TODO: Only load / unload arrays if we have to. */ static inline void unloadVertexData(const struct wined3d_context *context) @@ -3957,10 +3993,12 @@ static inline void unloadVertexData(const struct wined3d_context *context) glDisableClientState(GL_VERTEX_ARRAY); glDisableClientState(GL_NORMAL_ARRAY); glDisableClientState(GL_COLOR_ARRAY); - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (context->gl_info->supported[EXT_SECONDARY_COLOR]) + { glDisableClientState(GL_SECONDARY_COLOR_ARRAY_EXT); } - if (GL_SUPPORT(ARB_VERTEX_BLEND)) { + if (context->gl_info->supported[ARB_VERTEX_BLEND]) + { glDisableClientState(GL_WEIGHT_ARRAY_ARB); } unloadTexCoords(context); @@ -3996,7 +4034,7 @@ static inline void unloadNumberedArrays(IWineD3DStateBlockImpl *stateblock, stru static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, const struct wined3d_stream_info *stream_info, struct wined3d_context *context) { - GLuint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? ~0U : 0; + GLuint curVBO = context->gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0; int i; const UINT *offset = stateblock->streamOffset; struct wined3d_buffer *vb; @@ -4098,7 +4136,7 @@ static inline void loadNumberedArrays(IWineD3DStateBlockImpl *stateblock, GL_EXTCALL(glVertexAttrib4NubvARB(i, ptr)); break; case WINED3DFMT_B8G8R8A8_UNORM: - if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA)) + if (context->gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) { const DWORD *src = (const DWORD *)ptr; DWORD c = *src & 0xff00ff00; @@ -4172,7 +4210,7 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB const struct wined3d_stream_info *si) { const UINT *offset = stateblock->streamOffset; - GLuint curVBO = GL_SUPPORT(ARB_VERTEX_BUFFER_OBJECT) ? ~0U : 0; + GLuint curVBO = context->gl_info->supported[ARB_VERTEX_BUFFER_OBJECT] ? ~0U : 0; const struct wined3d_stream_info_element *e; TRACE("Using fast vertex array code\n"); @@ -4186,7 +4224,8 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB { e = &si->elements[WINED3D_FFP_BLENDWEIGHT]; - if (GL_SUPPORT(ARB_VERTEX_BLEND)) { + if (context->gl_info->supported[ARB_VERTEX_BLEND]) + { TRACE("Blend %d %p %d\n", e->format_desc->component_count, e->data + stateblock->loadBaseVertexIndex * e->stride, e->stride + offset[e->stream_idx]); @@ -4227,8 +4266,11 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB */ WARN("unsupported blending in openGl\n"); } - } else { - if (GL_SUPPORT(ARB_VERTEX_BLEND)) { + } + else + { + if (context->gl_info->supported[ARB_VERTEX_BLEND]) + { static const GLbyte one = 1; GL_EXTCALL(glWeightbvARB(1, &one)); checkGLcall("glWeightivARB(gl_info->max_blends, weights)"); @@ -4339,7 +4381,8 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB VTRACE(("glSecondaryColorPointer(4, GL_UNSIGNED_BYTE, %d, %p)\n", e->stride, e->data)); e = &si->elements[WINED3D_FFP_SPECULAR]; - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + if (context->gl_info->supported[EXT_SECONDARY_COLOR]) + { GLenum type = e->format_desc->gl_vtx_type; GLint format = e->format_desc->gl_vtx_format; @@ -4386,9 +4429,11 @@ static void loadVertexData(const struct wined3d_context *context, IWineD3DStateB /* Missing specular color is not critical, no warnings */ VTRACE(("Specular colour is not supported in this GL implementation\n")); } - - } else { - if (GL_SUPPORT(EXT_SECONDARY_COLOR)) { + } + else + { + if (context->gl_info->supported[EXT_SECONDARY_COLOR]) + { GL_EXTCALL(glSecondaryColor3fEXT)(0, 0, 0); checkGLcall("glSecondaryColor3fEXT(0, 0, 0)"); } else { @@ -4468,7 +4513,8 @@ static void streamsrc(DWORD state, IWineD3DStateBlockImpl *stateblock, struct wi else { WORD slow_mask = (1 << WINED3D_FFP_PSIZE); - slow_mask |= -!GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA) & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); + slow_mask |= -!context->gl_info->supported[EXT_VERTEX_ARRAY_BGRA] + & ((1 << WINED3D_FFP_DIFFUSE) | (1 << WINED3D_FFP_SPECULAR)); if (fixup || (!dataLocations->position_transformed && !(dataLocations->use_map & slow_mask))) @@ -5557,7 +5603,6 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = { }; #undef GLINFO_LOCATION -#define GLINFO_LOCATION (*gl_info) /* Context activation is done by the caller. */ static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { } @@ -5574,9 +5619,10 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_SELECTARG2 | WINED3DTEXOPCAPS_DISABLE; - if (GL_SUPPORT(ARB_TEXTURE_ENV_COMBINE) || - GL_SUPPORT(EXT_TEXTURE_ENV_COMBINE) || - GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) { + if (gl_info->supported[ARB_TEXTURE_ENV_COMBINE] + || gl_info->supported[EXT_TEXTURE_ENV_COMBINE] + || gl_info->supported[NV_TEXTURE_ENV_COMBINE4]) + { pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA | WINED3DTEXOPCAPS_BLENDTEXTUREALPHA | WINED3DTEXOPCAPS_BLENDFACTORALPHA | @@ -5584,15 +5630,16 @@ static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WINED3DTEXOPCAPS_LERP | WINED3DTEXOPCAPS_SUBTRACT; } - if (GL_SUPPORT(ATI_TEXTURE_ENV_COMBINE3) || - GL_SUPPORT(NV_TEXTURE_ENV_COMBINE4)) { + if (gl_info->supported[ATI_TEXTURE_ENV_COMBINE3] + || gl_info->supported[NV_TEXTURE_ENV_COMBINE4]) + { pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_ADDSMOOTH | WINED3DTEXOPCAPS_MULTIPLYADD | WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR | WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA | WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM; } - if (GL_SUPPORT(ARB_TEXTURE_ENV_DOT3)) + if (gl_info->supported[ARB_TEXTURE_ENV_DOT3]) pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_DOTPRODUCT3; pCaps->MaxTextureBlendStages = gl_info->limits.texture_stages; @@ -5693,7 +5740,7 @@ HRESULT compile_state_table(struct StateEntry *StateTable, APPLYSTATEFUNC **dev_ */ if(set[cur[i].state]) continue; /* Skip state lines depending on unsupported extensions */ - if (!GL_SUPPORT(cur[i].extension)) continue; + if (!gl_info->supported[cur[i].extension]) continue; set[cur[i].state] = TRUE; /* In some cases having an extension means that nothing has to be * done for a state, e.g. if GL_ARB_texture_non_power_of_two is @@ -5760,4 +5807,3 @@ out_of_mem: return E_OUTOFMEMORY; } -#undef GLINFO_LOCATION diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c index 1c57e11bf90..03f027b9060 100644 --- a/dlls/wined3d/surface.c +++ b/dlls/wined3d/surface.c @@ -553,6 +553,7 @@ static void surface_upload_data(IWineD3DSurfaceImpl *This, GLenum internal, GLsi * the correct texture. */ /* Context activation is done by the caller. */ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, GLsizei width, GLsizei height, GLenum format, GLenum type) { + const struct wined3d_gl_info *gl_info = &This->resource.wineD3DDevice->adapter->gl_info; const struct GlPixelFormatDesc *format_desc = This->resource.format_desc; BOOL enable_client_storage = FALSE; const BYTE *mem = NULL; @@ -565,7 +566,8 @@ static void surface_allocate_surface(IWineD3DSurfaceImpl *This, GLenum internal, ENTER_GL(); - if(GL_SUPPORT(APPLE_CLIENT_STORAGE)) { + if (gl_info->supported[APPLE_CLIENT_STORAGE]) + { if(This->Flags & (SFLAG_NONPOW2 | SFLAG_DIBSECTION | SFLAG_OVERSIZE | SFLAG_CONVERTED) || This->resource.allocatedMemory == NULL) { /* In some cases we want to disable client storage. * SFLAG_NONPOW2 has a bigger opengl texture than the client memory, and different pitches @@ -1221,7 +1223,11 @@ static void read_from_framebuffer_texture(IWineD3DSurfaceImpl *This, BOOL srgb) TRACE("Updated target %d\n", This->texture_target); } -static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) { +static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) +{ + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + /* Performance optimization: Count how often a surface is locked, if it is locked regularly do not throw away the system memory copy. * This avoids the need to download the surface from opengl all the time. The surface is still downloaded if the opengl texture is * changed @@ -1238,12 +1244,11 @@ static void surface_prepare_system_memory(IWineD3DSurfaceImpl *This) { /* Create a PBO for dynamically locked surfaces but don't do it for converted or non-pow2 surfaces. * Also don't create a PBO for systemmem surfaces. */ - if (GL_SUPPORT(ARB_PIXEL_BUFFER_OBJECT) && (This->Flags & SFLAG_DYNLOCK) + if (gl_info->supported[ARB_PIXEL_BUFFER_OBJECT] && (This->Flags & SFLAG_DYNLOCK) && !(This->Flags & (SFLAG_PBO | SFLAG_CONVERTED | SFLAG_NONPOW2)) && (This->resource.pool != WINED3DPOOL_SYSTEMMEM)) { GLenum error; - IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; struct wined3d_context *context; context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); @@ -1735,6 +1740,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ BOOL colorkey_active = need_alpha_ck && (This->CKeyFlags & WINEDDSD_CKSRCBLT); const struct GlPixelFormatDesc *glDesc = This->resource.format_desc; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; /* Default values: From the surface */ *format = glDesc->glFormat; @@ -1768,11 +1774,10 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ * in which the main render target uses p8. Some games like GTA Vice City use P8 for texturing which * conflicts with this. */ - if( !(GL_SUPPORT(EXT_PALETTED_TEXTURE) || - (GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && - device->render_targets && - This == (IWineD3DSurfaceImpl*)device->render_targets[0])) || - colorkey_active || !use_texturing ) { + if (!(gl_info->supported[EXT_PALETTED_TEXTURE] || (gl_info->supported[ARB_FRAGMENT_PROGRAM] + && device->render_targets && This == (IWineD3DSurfaceImpl*)device->render_targets[0])) + || colorkey_active || !use_texturing) + { *format = GL_RGBA; *internal = GL_RGBA; *type = GL_UNSIGNED_BYTE; @@ -1783,7 +1788,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ *convert = CONVERT_PALETTED; } } - else if(!GL_SUPPORT(EXT_PALETTED_TEXTURE) && GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) { + else if (!gl_info->supported[EXT_PALETTED_TEXTURE] && gl_info->supported[ARB_FRAGMENT_PROGRAM]) + { *format = GL_ALPHA; *type = GL_UNSIGNED_BYTE; *target_bpp = 1; @@ -1840,7 +1846,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ break; case WINED3DFMT_R8G8_SNORM: - if (GL_SUPPORT(NV_TEXTURE_SHADER)) break; + if (gl_info->supported[NV_TEXTURE_SHADER]) break; *convert = CONVERT_V8U8; *format = GL_BGR; *type = GL_UNSIGNED_BYTE; @@ -1849,7 +1855,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ case WINED3DFMT_R5G5_SNORM_L6_UNORM: *convert = CONVERT_L6V5U5; - if(GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (gl_info->supported[NV_TEXTURE_SHADER]) + { *target_bpp = 3; /* Use format and types from table */ } else { @@ -1863,7 +1870,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ case WINED3DFMT_R8G8_SNORM_L8X8_UNORM: *convert = CONVERT_X8L8V8U8; *target_bpp = 4; - if(GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (gl_info->supported[NV_TEXTURE_SHADER]) + { /* Use formats from gl table. It is a bit unfortunate, but the conversion * is needed to set the X format to 255 to get 1.0 for alpha when sampling * the texture. OpenGL can't use GL_DSDT8_MAG8_NV as internal format with @@ -1877,7 +1885,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ break; case WINED3DFMT_R8G8B8A8_SNORM: - if (GL_SUPPORT(NV_TEXTURE_SHADER)) break; + if (gl_info->supported[NV_TEXTURE_SHADER]) break; *convert = CONVERT_Q8W8V8U8; *format = GL_BGRA; *type = GL_UNSIGNED_BYTE; @@ -1885,7 +1893,7 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ break; case WINED3DFMT_R16G16_SNORM: - if (GL_SUPPORT(NV_TEXTURE_SHADER)) break; + if (gl_info->supported[NV_TEXTURE_SHADER]) break; *convert = CONVERT_V16U16; *format = GL_BGR; *type = GL_UNSIGNED_SHORT; @@ -1925,8 +1933,8 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ break; case WINED3DFMT_S1_UINT_D15_UNORM: - if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT) - || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL)) + if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] + || gl_info->supported[EXT_PACKED_DEPTH_STENCIL]) { *convert = CONVERT_D15S1; *target_bpp = 4; @@ -1934,15 +1942,15 @@ HRESULT d3dfmt_get_conv(IWineD3DSurfaceImpl *This, BOOL need_alpha_ck, BOOL use_ break; case WINED3DFMT_S4X4_UINT_D24_UNORM: - if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT) - || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL)) + if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] + || gl_info->supported[EXT_PACKED_DEPTH_STENCIL]) { *convert = CONVERT_D24X4S4; } break; case WINED3DFMT_S8_UINT_D24_FLOAT: - if (GL_SUPPORT(ARB_DEPTH_BUFFER_FLOAT)) + if (gl_info->supported[ARB_DEPTH_BUFFER_FLOAT]) { *convert = CONVERT_D24FS8; *target_bpp = 8; @@ -2039,6 +2047,8 @@ static void d3dfmt_p8_init_palette(IWineD3DSurfaceImpl *This, BYTE table[256][4] static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UINT width, UINT height, UINT outpitch, CONVERT_TYPES convert, IWineD3DSurfaceImpl *This) { + IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; const BYTE *source; BYTE *dest; TRACE("(%p)->(%p),(%d,%d,%d,%d,%p)\n", src, dst, pitch, height, outpitch, convert,This); @@ -2248,7 +2258,8 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI const WORD *Source; unsigned char *Dest; - if(GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (gl_info->supported[NV_TEXTURE_SHADER]) + { /* This makes the gl surface bigger(24 bit instead of 16), but it works with * fixed function and shaders without further conversion once the surface is * loaded @@ -2302,7 +2313,8 @@ static HRESULT d3dfmt_convert_surface(const BYTE *src, BYTE *dst, UINT pitch, UI const DWORD *Source; unsigned char *Dest; - if(GL_SUPPORT(NV_TEXTURE_SHADER)) { + if (gl_info->supported[NV_TEXTURE_SHADER]) + { /* This implementation works with the fixed function pipeline and shaders * without further modification after converting the surface. */ @@ -2475,11 +2487,12 @@ static void d3dfmt_p8_upload_palette(IWineD3DSurface *iface, CONVERT_TYPES conve IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *)iface; BYTE table[256][4]; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; d3dfmt_p8_init_palette(This, table, (convert == CONVERT_PALETTED_CK)); /* Try to use the paletted texture extension */ - if(GL_SUPPORT(EXT_PALETTED_TEXTURE)) + if (gl_info->supported[EXT_PALETTED_TEXTURE]) { TRACE("Using GL_EXT_PALETTED_TEXTURE for 8-bit paletted texture support\n"); ENTER_GL(); @@ -4170,10 +4183,13 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) { This->texture_target = GL_TEXTURE_2D; /* Non-power2 support */ - if (GL_SUPPORT(ARB_TEXTURE_NON_POWER_OF_TWO) || GL_SUPPORT(WINE_NORMALIZED_TEXRECT)) { + if (gl_info->supported[ARB_TEXTURE_NON_POWER_OF_TWO] || gl_info->supported[WINE_NORMALIZED_TEXRECT]) + { pow2Width = This->currentDesc.Width; pow2Height = This->currentDesc.Height; - } else { + } + else + { /* Find the nearest pow2 match */ pow2Width = pow2Height = 1; while (pow2Width < This->currentDesc.Width) pow2Width <<= 1; @@ -4222,8 +4238,9 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_PrivateSetup(IWineD3DSurface *iface) { is used in combination with texture uploads (RTL_READTEX/RTL_TEXTEX). The reason is that EXT_PALETTED_TEXTURE doesn't work in combination with ARB_TEXTURE_RECTANGLE. */ - if (This->Flags & SFLAG_NONPOW2 && GL_SUPPORT(ARB_TEXTURE_RECTANGLE) - && !(This->resource.format_desc->format == WINED3DFMT_P8_UINT && GL_SUPPORT(EXT_PALETTED_TEXTURE) + if (This->Flags & SFLAG_NONPOW2 && gl_info->supported[ARB_TEXTURE_RECTANGLE] + && !(This->resource.format_desc->format == WINED3DFMT_P8_UINT + && gl_info->supported[EXT_PALETTED_TEXTURE] && wined3d_settings.rendertargetlock_mode == RTL_READTEX)) { This->texture_target = GL_TEXTURE_RECTANGLE_ARB; @@ -4787,6 +4804,7 @@ static inline void surface_blt_to_drawable(IWineD3DSurfaceImpl *This, const RECT static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, DWORD flag, const RECT *rect) { IWineD3DSurfaceImpl *This = (IWineD3DSurfaceImpl *) iface; IWineD3DDeviceImpl *device = This->resource.wineD3DDevice; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; GLenum format, internal, type; CONVERT_TYPES convert; int bpp; @@ -4973,7 +4991,7 @@ static HRESULT WINAPI IWineD3DSurfaceImpl_LoadLocation(IWineD3DSurface *iface, D This->Flags |= SFLAG_CONVERTED; } else if (This->resource.format_desc->format == WINED3DFMT_P8_UINT - && (GL_SUPPORT(EXT_PALETTED_TEXTURE) || GL_SUPPORT(ARB_FRAGMENT_PROGRAM))) + && (gl_info->supported[EXT_PALETTED_TEXTURE] || gl_info->supported[ARB_FRAGMENT_PROGRAM])) { d3dfmt_p8_upload_palette(iface, convert); This->Flags &= ~SFLAG_CONVERTED; @@ -5160,16 +5178,21 @@ static HRESULT ffp_blit_set(IWineD3DDevice *iface, const struct GlPixelFormatDes } /* Context activation is done by the caller. */ -static void ffp_blit_unset(IWineD3DDevice *iface) { +static void ffp_blit_unset(IWineD3DDevice *iface) +{ IWineD3DDeviceImpl *device = (IWineD3DDeviceImpl *) iface; + const struct wined3d_gl_info *gl_info = &device->adapter->gl_info; + ENTER_GL(); glDisable(GL_TEXTURE_2D); checkGLcall("glDisable(GL_TEXTURE_2D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } diff --git a/dlls/wined3d/swapchain.c b/dlls/wined3d/swapchain.c index cab916ba32e..a23166a2219 100644 --- a/dlls/wined3d/swapchain.c +++ b/dlls/wined3d/swapchain.c @@ -279,7 +279,9 @@ static HRESULT WINAPI IWineD3DSwapChainImpl_Present(IWineD3DSwapChain *iface, CO } } - if(This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE && GL_SUPPORT(SGI_VIDEO_SYNC)) { + if (This->presentParms.PresentationInterval != WINED3DPRESENT_INTERVAL_IMMEDIATE + && context->gl_info->supported[SGI_VIDEO_SYNC]) + { retval = GL_EXTCALL(glXGetVideoSyncSGI(&sync)); if(retval != 0) { ERR("glXGetVideoSyncSGI failed(retval = %d\n", retval); diff --git a/dlls/wined3d/utils.c b/dlls/wined3d/utils.c index d9d65039d12..0eedc7acb2e 100644 --- a/dlls/wined3d/utils.c +++ b/dlls/wined3d/utils.c @@ -574,8 +574,6 @@ static BOOL init_format_compression_info(struct wined3d_gl_info *gl_info) return TRUE; } -#define GLINFO_LOCATION (*gl_info) - /* Context activation is done by the caller. */ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct GlPixelFormatDesc *format_desc) { @@ -663,8 +661,8 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct GlPix { GLuint rb; - if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT) - || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL)) + if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] + || gl_info->supported[EXT_PACKED_DEPTH_STENCIL]) { gl_info->fbo_ops.glGenRenderbuffers(1, &rb); gl_info->fbo_ops.glBindRenderbuffer(GL_RENDERBUFFER, rb); @@ -683,8 +681,8 @@ static void check_fbo_compat(const struct wined3d_gl_info *gl_info, struct GlPix format_desc->Flags &= ~WINED3DFMT_FLAG_POSTPIXELSHADER_BLENDING; } - if (GL_SUPPORT(ARB_FRAMEBUFFER_OBJECT) - || GL_SUPPORT(EXT_PACKED_DEPTH_STENCIL)) + if (gl_info->supported[ARB_FRAMEBUFFER_OBJECT] + || gl_info->supported[EXT_PACKED_DEPTH_STENCIL]) { gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_ATTACHMENT, GL_RENDERBUFFER, 0); gl_info->fbo_ops.glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, 0); @@ -771,7 +769,7 @@ static BOOL init_format_texture_info(struct wined3d_gl_info *gl_info) return FALSE; } - if (!GL_SUPPORT(gl_formats_template[i].extension)) continue; + if (!gl_info->supported[gl_formats_template[i].extension]) continue; desc = &gl_info->gl_formats[fmt_idx]; desc->glInternal = gl_formats_template[i].glInternal; @@ -911,7 +909,7 @@ static void init_format_filter_info(struct wined3d_gl_info *gl_info, enum wined3 if(wined3d_settings.offscreen_rendering_mode != ORM_FBO) { WARN("No FBO support, or no FBO ORM, guessing filter info from GL caps\n"); - if (vendor == VENDOR_NVIDIA && GL_SUPPORT(ARB_TEXTURE_FLOAT)) + if (vendor == VENDOR_NVIDIA && gl_info->supported[ARB_TEXTURE_FLOAT]) { TRACE("Nvidia card with texture_float support: Assuming float16 blending\n"); filtered = TRUE; @@ -990,7 +988,7 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) * returns 0.0 when sampling from it, DirectX 1.0. So we always have in-shader * conversion for this format. */ - if (!GL_SUPPORT(NV_TEXTURE_SHADER)) + if (!gl_info->supported[NV_TEXTURE_SHADER]) { idx = getFmtIdx(WINED3DFMT_R8G8_SNORM); gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc( @@ -1009,7 +1007,7 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); } - if (!GL_SUPPORT(NV_TEXTURE_SHADER)) + if (!gl_info->supported[NV_TEXTURE_SHADER]) { /* If GL_NV_texture_shader is not supported, those formats are converted, incompatibly * with each other @@ -1033,20 +1031,20 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) */ } - if (GL_SUPPORT(EXT_TEXTURE_COMPRESSION_RGTC)) + if (gl_info->supported[EXT_TEXTURE_COMPRESSION_RGTC]) { idx = getFmtIdx(WINED3DFMT_ATI2N); gl_info->gl_formats[idx].color_fixup = create_color_fixup_desc( 0, CHANNEL_SOURCE_Y, 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); } - else if (GL_SUPPORT(ATI_TEXTURE_COMPRESSION_3DC)) + else if (gl_info->supported[ATI_TEXTURE_COMPRESSION_3DC]) { idx = getFmtIdx(WINED3DFMT_ATI2N); gl_info->gl_formats[idx].color_fixup= create_color_fixup_desc( 0, CHANNEL_SOURCE_X, 0, CHANNEL_SOURCE_W, 0, CHANNEL_SOURCE_ONE, 0, CHANNEL_SOURCE_ONE); } - if (!GL_SUPPORT(APPLE_YCBCR_422)) + if (!gl_info->supported[APPLE_YCBCR_422]) { idx = getFmtIdx(WINED3DFMT_YUY2); gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YUY2); @@ -1059,13 +1057,13 @@ static void apply_format_fixups(struct wined3d_gl_info *gl_info) gl_info->gl_formats[idx].heightscale = 1.5f; gl_info->gl_formats[idx].color_fixup = create_yuv_fixup_desc(YUV_FIXUP_YV12); - if (GL_SUPPORT(EXT_VERTEX_ARRAY_BGRA)) + if (gl_info->supported[EXT_VERTEX_ARRAY_BGRA]) { idx = getFmtIdx(WINED3DFMT_B8G8R8A8_UNORM); gl_info->gl_formats[idx].gl_vtx_format = GL_BGRA; } - if (GL_SUPPORT(ARB_HALF_FLOAT_VERTEX)) + if (gl_info->supported[ARB_HALF_FLOAT_VERTEX]) { /* Do not change the size of the type, it is CPU side. We have to change the GPU-side information though. * It is the job of the vertex buffer code to make sure that the vbos have the right format */ @@ -2586,11 +2584,13 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock case GL_TEXTURE_2D: glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } @@ -2602,7 +2602,8 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock checkGLcall("glDisable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } @@ -2610,11 +2611,13 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock checkGLcall("glEnable(GL_TEXTURE_RECTANGLE_ARB)"); break; case GL_TEXTURE_3D: - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } @@ -2628,7 +2631,8 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock checkGLcall("glDisable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } @@ -2641,11 +2645,13 @@ void texture_activate_dimensions(DWORD stage, IWineD3DStateBlockImpl *stateblock checkGLcall("glEnable(GL_TEXTURE_2D)"); glDisable(GL_TEXTURE_3D); checkGLcall("glDisable(GL_TEXTURE_3D)"); - if(GL_SUPPORT(ARB_TEXTURE_CUBE_MAP)) { + if (gl_info->supported[ARB_TEXTURE_CUBE_MAP]) + { glDisable(GL_TEXTURE_CUBE_MAP_ARB); checkGLcall("glDisable(GL_TEXTURE_CUBE_MAP_ARB)"); } - if(GL_SUPPORT(ARB_TEXTURE_RECTANGLE)) { + if (gl_info->supported[ARB_TEXTURE_RECTANGLE]) + { glDisable(GL_TEXTURE_RECTANGLE_ARB); checkGLcall("glDisable(GL_TEXTURE_RECTANGLE_ARB)"); } diff --git a/dlls/wined3d/volume.c b/dlls/wined3d/volume.c index b428e3296db..bb5827e9020 100644 --- a/dlls/wined3d/volume.c +++ b/dlls/wined3d/volume.c @@ -30,6 +30,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface); /* Context activation is done by the caller. */ static void volume_bind_and_dirtify(IWineD3DVolume *iface) { IWineD3DVolumeImpl *This = (IWineD3DVolumeImpl *)iface; + const struct wined3d_gl_info *gl_info = &This->resource.wineD3DDevice->adapter->gl_info; IWineD3DVolumeTexture *texture; DWORD active_sampler; @@ -44,7 +45,8 @@ static void volume_bind_and_dirtify(IWineD3DVolume *iface) { * * TODO: Track the current active texture per GL context instead of using glGet */ - if (GL_SUPPORT(ARB_MULTITEXTURE)) { + if (gl_info->supported[ARB_MULTITEXTURE]) + { GLint active_texture; ENTER_GL(); glGetIntegerv(GL_ACTIVE_TEXTURE, &active_texture); diff --git a/dlls/wined3d/volumetexture.c b/dlls/wined3d/volumetexture.c index a21211d1b9c..4cea3a01638 100644 --- a/dlls/wined3d/volumetexture.c +++ b/dlls/wined3d/volumetexture.c @@ -26,8 +26,6 @@ WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture); -#define GLINFO_LOCATION (*gl_info) - static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINED3DSRGB srgb) { /* Override the IWineD3DResource Preload method. */ @@ -42,7 +40,7 @@ static void volumetexture_internal_preload(IWineD3DBaseTexture *iface, enum WINE TRACE("(%p) : About to load texture.\n", This); if (!device->isInDraw) context = context_acquire(device, NULL, CTXUSAGE_RESOURCELOAD); - else if (GL_SUPPORT(EXT_TEXTURE_SRGB) && This->baseTexture.bindCount > 0) + else if (gl_info->supported[EXT_TEXTURE_SRGB] && This->baseTexture.bindCount > 0) { srgb_mode = device->stateBlock->samplerState[This->baseTexture.sampler][WINED3DSAMP_SRGBTEXTURE]; srgb_was_toggled = This->baseTexture.is_srgb != srgb_mode; @@ -97,8 +95,6 @@ static void volumetexture_cleanup(IWineD3DVolumeTextureImpl *This) basetexture_cleanup((IWineD3DBaseTexture *)This); } -#undef GLINFO_LOCATION - /* ******************************************* IWineD3DTexture IUnknown parts follow ******************************************* */ diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h index 3c1e631abdb..d1400aa6083 100644 --- a/dlls/wined3d/wined3d_private.h +++ b/dlls/wined3d/wined3d_private.h @@ -745,7 +745,6 @@ extern int num_lock DECLSPEC_HIDDEN; /* GL related defines */ /* ------------------ */ -#define GL_SUPPORT(ExtName) (GLINFO_LOCATION.supported[ExtName] != 0) #define GL_EXTCALL(FuncName) (GLINFO_LOCATION.FuncName) #define D3DCOLOR_B_R(dw) (((dw) >> 16) & 0xFF)