Commit a460a2df authored by Stefan Dösinger's avatar Stefan Dösinger Committed by Alexandre Julliard

wined3d: Store the gl information in a per adapter structure and initialize it only once.

parent 6089fe86
......@@ -104,7 +104,7 @@ void shader_arb_load_constants(
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl*)deviceImpl->wineD3D)->gl_info;
WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
if (useVertexShader) {
IWineD3DBaseShaderImpl* vshader = (IWineD3DBaseShaderImpl*) stateBlock->vertexShader;
......@@ -383,7 +383,7 @@ static void shader_hw_sample(SHADER_OPCODE_ARG* arg, DWORD sampler_idx, const ch
IWineD3DPixelShaderImpl* This = (IWineD3DPixelShaderImpl*) arg->shader;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
IWineD3DBaseTextureImpl *texture = (IWineD3DBaseTextureImpl *) deviceImpl->stateBlock->textures[sampler_idx];
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(((IWineD3DDeviceImpl *)(This->baseShader.device))->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info;
SHADER_BUFFER* buffer = arg->buffer;
DWORD sampler_type = arg->reg_maps->samplers[sampler_idx] & WINED3DSP_TEXTURETYPE_MASK;
......@@ -1033,7 +1033,7 @@ static GLuint create_arb_blt_fragment_program(WineD3D_GL_Info *gl_info) {
static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
if (useVS) {
TRACE("Using vertex shader\n");
......@@ -1074,7 +1074,7 @@ static void shader_arb_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
static GLuint vprogram_id = 0;
static GLuint fprogram_id = 0;
......@@ -1089,7 +1089,7 @@ static void shader_arb_select_depth_blt(IWineD3DDevice *iface) {
static void shader_arb_cleanup(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) glDisable(GL_VERTEX_PROGRAM_ARB);
if (GL_SUPPORT(ARB_FRAGMENT_PROGRAM)) glDisable(GL_FRAGMENT_PROGRAM_ARB);
}
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static const Wined3dTextureStateMap textureObjectSamplerStates[] = {
{WINED3DSAMP_ADDRESSU, WINED3DSAMP_ADDRESSU},
......
......@@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
#define GLINFO_LOCATION This->adapter->gl_info
/*****************************************************************************
* Context_MarkStateDirty
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
static const GLenum cube_targets[6] = {
GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB,
......
......@@ -33,7 +33,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
#define GLINFO_LOCATION This->adapter->gl_info
/* Define the default light parameters as specified by MSDN */
const WINED3DLIGHT WINED3D_default_light = {
......@@ -1855,12 +1855,7 @@ static HRESULT WINAPI IWineD3DDeviceImpl_Init3D(IWineD3DDevice *iface, WINED3DPR
/* Set up some starting GL setup */
ENTER_GL();
/*
* Initialize openGL extension related variables
* with Default values
*/
((IWineD3DImpl *) This->wineD3D)->isGLInfoValid = IWineD3DImpl_FillGLCaps(This->wineD3D, swapchain->context[0]->display);
/* Setup all the devices defaults */
IWineD3DStateBlock_InitStartupStateBlock((IWineD3DStateBlock *)This->stateBlock);
#if 0
......
......@@ -27,7 +27,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_draw);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
#define GLINFO_LOCATION This->adapter->gl_info
#include <stdio.h>
......
......@@ -287,7 +287,7 @@ void shader_glsl_load_constants(
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) device;
IWineD3DStateBlockImpl* stateBlock = deviceImpl->stateBlock;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl*) deviceImpl->wineD3D)->gl_info;
WineD3D_GL_Info *gl_info = &deviceImpl->adapter->gl_info;
GLhandleARB *constant_locations;
struct list *constant_list;
......@@ -583,7 +583,7 @@ static void shader_glsl_get_register_name(
DWORD regtype = shader_get_regtype(param);
IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) arg->shader;
IWineD3DDeviceImpl* deviceImpl = (IWineD3DDeviceImpl*) This->baseShader.device;
WineD3D_GL_Info* gl_info = &((IWineD3DImpl*)deviceImpl->wineD3D)->gl_info;
WineD3D_GL_Info* gl_info = &deviceImpl->adapter->gl_info;
char pshader = shader_is_pshader_version(This->baseShader.hex_version);
char tmpStr[50];
......@@ -2099,7 +2099,7 @@ static struct glsl_shader_prog_link *get_glsl_program_entry(IWineD3DDeviceImpl *
void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_link *entry) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
glsl_program_key_t *key;
key = HeapAlloc(GetProcessHeap(), 0, sizeof(glsl_program_key_t));
......@@ -2125,7 +2125,7 @@ void delete_glsl_program_entry(IWineD3DDevice *iface, struct glsl_shader_prog_li
*/
static void set_glsl_shader_program(IWineD3DDevice *iface, BOOL use_ps, BOOL use_vs) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
IWineD3DPixelShader *pshader = This->stateBlock->pixelShader;
IWineD3DVertexShader *vshader = This->stateBlock->vertexShader;
struct glsl_shader_prog_link *entry = NULL;
......@@ -2250,7 +2250,7 @@ static GLhandleARB create_glsl_blt_shader(WineD3D_GL_Info *gl_info) {
static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
GLhandleARB program_id = 0;
if (useVS || usePS) set_glsl_shader_program(iface, usePS, useVS);
......@@ -2264,7 +2264,7 @@ static void shader_glsl_select(IWineD3DDevice *iface, BOOL usePS, BOOL useVS) {
static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
static GLhandleARB program_id = 0;
static GLhandleARB loc = -1;
......@@ -2279,7 +2279,7 @@ static void shader_glsl_select_depth_blt(IWineD3DDevice *iface) {
static void shader_glsl_cleanup(IWineD3DDevice *iface) {
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *)iface;
WineD3D_GL_Info *gl_info = &((IWineD3DImpl *)(This->wineD3D))->gl_info;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
GL_EXTCALL(glUseProgramObjectARB(0));
}
......
......@@ -25,7 +25,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DIndexBuffer IUnknown parts follow
......
......@@ -31,7 +31,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->baseShader.device)->wineD3D))->gl_info
#define GLINFO_LOCATION ((IWineD3DDeviceImpl *) This->baseShader.device)->adapter->gl_info
#if 0 /* Must not be 1 in cvs version */
# define PSTRACE(A) TRACE A
......
......@@ -33,7 +33,7 @@
*/
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DQuery IUnknown parts follow
......
......@@ -34,7 +34,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
WINE_DECLARE_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(stateblock->wineD3DDevice->wineD3D))->gl_info
#define GLINFO_LOCATION stateblock->wineD3DDevice->adapter->gl_info
static void state_nogl(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
/* Used for states which are not mapped to a gl state as-is, but used somehow different,
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->wineD3DDevice->adapter->gl_info
/***************************************
* Stateblock helper functions follow
......
......@@ -30,7 +30,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_surface);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
typedef enum {
NO_CONVERSION,
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d_texture);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DTexture IUnknown parts follow
......
......@@ -27,7 +27,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
#define GLINFO_LOCATION This->adapter->gl_info
/*****************************************************************************
* Pixel format array
......@@ -1217,7 +1217,6 @@ void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP
/* Setup the texture operations texture stage states */
void set_tex_op(IWineD3DDevice *iface, BOOL isAlpha, int Stage, WINED3DTEXTUREOP op, DWORD arg1, DWORD arg2, DWORD arg3)
{
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->wineD3D))->gl_info
GLenum src1, src2, src3;
GLenum opr1, opr2, opr3;
GLenum comb_target;
......@@ -2577,7 +2576,7 @@ DWORD get_flexible_vertex_size(DWORD d3dvtVertexType) {
* FALSE otherwise
*
*********************************************************************/
#define GLINFO_LOCATION ((IWineD3DImpl *)(This->resource.wineD3DDevice->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
BOOL CalculateTexRect(IWineD3DSurfaceImpl *This, RECT *Rect, float glTexCoord[4]) {
int x1 = Rect->left, x2 = Rect->right;
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
#define VB_MAXDECLCHANGES 100 /* After that number we stop converting */
#define VB_RESETDECLCHANGE 1000 /* Reset the changecount after that number of draws */
......
......@@ -31,7 +31,7 @@
WINE_DEFAULT_DEBUG_CHANNEL(d3d_shader);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->baseShader.device)->wineD3D))->gl_info
#define GLINFO_LOCATION ((IWineD3DDeviceImpl *)This->baseShader.device)->adapter->gl_info
/* Shader debugging - Change the following line to enable debugging of software
vertex shaders */
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DVolume IUnknown parts follow
......
......@@ -24,7 +24,7 @@
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION ((IWineD3DImpl *)(((IWineD3DDeviceImpl *)This->resource.wineD3DDevice)->wineD3D))->gl_info
#define GLINFO_LOCATION This->resource.wineD3DDevice->adapter->gl_info
/* *******************************************
IWineD3DTexture IUnknown parts follow
......
......@@ -59,7 +59,14 @@ long globalChangeGlRam(long glram){
}
IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *parent) {
IWineD3DImpl* object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
IWineD3DImpl* object;
if (!InitAdapters()) {
ERR("Failed to initialize direct3d adapters\n");
return NULL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IWineD3DImpl));
object->lpVtbl = &IWineD3D_Vtbl;
object->dxVersion = dxVersion;
object->ref = 1;
......@@ -72,7 +79,6 @@ IWineD3D* WINAPI WineDirect3DCreate(UINT SDKVersion, UINT dxVersion, IUnknown *p
}
TRACE("Created WineD3D object @ %p for d3d%d support\n", object, dxVersion);
return (IWineD3D *)object;
......
......@@ -537,9 +537,6 @@ WineD3DContext *CreateContext(IWineD3DDeviceImpl *This, IWineD3DSurfaceImpl *tar
void DestroyContext(IWineD3DDeviceImpl *This, WineD3DContext *context);
void apply_fbo_state(IWineD3DDevice *iface);
/* Routine to fill gl caps for swapchains and IWineD3D */
BOOL IWineD3DImpl_FillGLCaps(IWineD3D *iface, Display* display);
/* Macros for doing basic GPU detection based on opengl capabilities */
#define WINE_D3D6_CAPABLE(gl_info) (gl_info->supported[ARB_MULTITEXTURE])
#define WINE_D3D7_CAPABLE(gl_info) (gl_info->supported[ARB_TEXTURE_COMPRESSION] && gl_info->supported[ARB_TEXTURE_CUBE_MAP] && gl_info->supported[ARB_TEXTURE_ENV_DOT3])
......@@ -574,6 +571,16 @@ struct PLIGHTINFOEL {
/* The default light parameters */
extern const WINED3DLIGHT WINED3D_default_light;
/* The adapter structure */
struct WineD3DAdapter
{
POINT monitorPoint;
Display *display;
WineD3D_GL_Info gl_info;
};
extern BOOL InitAdapters(void);
/*****************************************************************************
* IWineD3D implementation structure
*/
......@@ -586,10 +593,6 @@ typedef struct IWineD3DImpl
/* WineD3D Information */
IUnknown *parent;
UINT dxVersion;
/* GL Information */
BOOL isGLInfoValid;
WineD3D_GL_Info gl_info;
} IWineD3DImpl;
extern const IWineD3DVtbl IWineD3D_Vtbl;
......@@ -620,6 +623,7 @@ struct IWineD3DDeviceImpl
/* WineD3D Information */
IUnknown *parent;
IWineD3D *wineD3D;
struct WineD3DAdapter *adapter;
/* Window styles to restore when switching fullscreen mode */
LONG style;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment