Commit d204540d authored by Jason Green's avatar Jason Green Committed by Alexandre Julliard

wined3d: Replaced USING_GLSL define with a new wined3d_settings option based on the registry.

parent a67488a2
...@@ -583,7 +583,7 @@ void generate_base_shader( ...@@ -583,7 +583,7 @@ void generate_base_shader(
*/ */
/* Pre-declare registers */ /* Pre-declare registers */
if (USING_GLSL) { if (wined3d_settings.shader_mode == SHADER_GLSL) {
generate_glsl_declarations(iface, &reg_maps, buffer); generate_glsl_declarations(iface, &reg_maps, buffer);
shader_addline(buffer, "void main() {\n"); shader_addline(buffer, "void main() {\n");
} else { } else {
...@@ -612,7 +612,8 @@ void generate_base_shader( ...@@ -612,7 +612,8 @@ void generate_base_shader(
/* Read opcode */ /* Read opcode */
opcode_token = *pToken++; opcode_token = *pToken++;
curOpcode = shader_get_opcode(iface, opcode_token); curOpcode = shader_get_opcode(iface, opcode_token);
hw_fct = USING_GLSL ? curOpcode->hw_glsl_fct : curOpcode->hw_fct; hw_fct = (wined3d_settings.shader_mode ==
SHADER_GLSL ? curOpcode->hw_glsl_fct : curOpcode->hw_fct);
/* Unknown opcode and its parameters */ /* Unknown opcode and its parameters */
if (NULL == curOpcode) { if (NULL == curOpcode) {
...@@ -692,7 +693,7 @@ void print_glsl_info_log( ...@@ -692,7 +693,7 @@ void print_glsl_info_log(
{ {
infoLog = (char *)HeapAlloc(GetProcessHeap(), 0, infologLength); infoLog = (char *)HeapAlloc(GetProcessHeap(), 0, infologLength);
GL_EXTCALL(glGetInfoLogARB(obj, infologLength, NULL, infoLog)); GL_EXTCALL(glGetInfoLogARB(obj, infologLength, NULL, infoLog));
FIXME("Error received from GLSL shader #%i: %s", obj, debugstr_a(infoLog)); FIXME("Error received from GLSL shader #%u: %s", obj, debugstr_a(infoLog));
HeapFree(GetProcessHeap(), 0, infoLog); HeapFree(GetProcessHeap(), 0, infoLog);
} }
} }
......
...@@ -1693,11 +1693,13 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D ...@@ -1693,11 +1693,13 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D
*pCaps->MaxStreams = MAX_STREAMS; *pCaps->MaxStreams = MAX_STREAMS;
*pCaps->MaxStreamStride = 1024; *pCaps->MaxStreamStride = 1024;
if (wined3d_settings.vs_mode == VS_HW && GL_SUPPORT(ARB_SHADING_LANGUAGE_100) && if (wined3d_settings.vs_mode == VS_HW && wined3d_settings.shader_mode == SHADER_GLSL
wined3d_settings.glslRequested && DeviceType != WINED3DDEVTYPE_REF) { && DeviceType != WINED3DDEVTYPE_REF) {
*pCaps->VertexShaderVersion = D3DVS_VERSION(3,0); *pCaps->VertexShaderVersion = D3DVS_VERSION(3,0);
TRACE_(d3d_caps)("Hardware vertex shader versions 2.0+ enabled\n"); TRACE_(d3d_caps)("Hardware vertex shader versions 2.0+ enabled\n");
} else if (wined3d_settings.vs_mode == VS_HW && GL_SUPPORT(ARB_VERTEX_PROGRAM) && DeviceType != WINED3DDEVTYPE_REF) { } else if (wined3d_settings.vs_mode == VS_HW
&& wined3d_settings.shader_mode == SHADER_ARB
&& DeviceType != WINED3DDEVTYPE_REF) {
*pCaps->VertexShaderVersion = D3DVS_VERSION(1,1); *pCaps->VertexShaderVersion = D3DVS_VERSION(1,1);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled\n"); TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled\n");
} else if (wined3d_settings.vs_mode == VS_SW || DeviceType == WINED3DDEVTYPE_REF) { } else if (wined3d_settings.vs_mode == VS_SW || DeviceType == WINED3DDEVTYPE_REF) {
...@@ -1715,13 +1717,15 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D ...@@ -1715,13 +1717,15 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D
*pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS; *pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
} }
if (wined3d_settings.ps_mode == PS_HW && GL_SUPPORT(ARB_SHADING_LANGUAGE_100) && if (wined3d_settings.ps_mode == PS_HW && wined3d_settings.shader_mode == SHADER_GLSL
wined3d_settings.glslRequested && DeviceType != WINED3DDEVTYPE_REF) { && DeviceType != WINED3DDEVTYPE_REF) {
*pCaps->PixelShaderVersion = D3DPS_VERSION(3,0); *pCaps->PixelShaderVersion = D3DPS_VERSION(3,0);
/* FIXME: The following line is card dependant. -1.0 to 1.0 is a safe default clamp range for now */ /* FIXME: The following line is card dependant. -1.0 to 1.0 is a safe default clamp range for now */
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Hardware pixel shader versions 2.0+ enabled\n"); TRACE_(d3d_caps)("Hardware pixel shader versions 2.0+ enabled\n");
} else if (wined3d_settings.ps_mode == PS_HW && GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && DeviceType != WINED3DDEVTYPE_REF) { } else if (wined3d_settings.ps_mode == PS_HW
&& wined3d_settings.shader_mode == SHADER_ARB
&& DeviceType != WINED3DDEVTYPE_REF) {
*pCaps->PixelShaderVersion = D3DPS_VERSION(1,4); *pCaps->PixelShaderVersion = D3DPS_VERSION(1,4);
*pCaps->PixelShader1xMaxValue = 1.0; *pCaps->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled\n"); TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled\n");
...@@ -1839,6 +1843,16 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, WINED3 ...@@ -1839,6 +1843,16 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, WINED3
IWineD3DImpl_FillGLCaps(&This->gl_info, IWineD3DImpl_GetAdapterDisplay(iface, Adapter)); IWineD3DImpl_FillGLCaps(&This->gl_info, IWineD3DImpl_GetAdapterDisplay(iface, Adapter));
LEAVE_GL(); LEAVE_GL();
/* Determine shader mode to use based on GL caps */
if (GL_SUPPORT(ARB_SHADING_LANGUAGE_100) && wined3d_settings.glslRequested
&& (wined3d_settings.vs_mode == VS_HW || wined3d_settings.ps_mode == PS_HW))
wined3d_settings.shader_mode = SHADER_GLSL;
else if ((GL_SUPPORT(ARB_VERTEX_PROGRAM) && wined3d_settings.vs_mode == VS_HW) ||
(GL_SUPPORT(ARB_FRAGMENT_PROGRAM) && wined3d_settings.ps_mode == PS_HW))
wined3d_settings.shader_mode = SHADER_ARB;
else
wined3d_settings.shader_mode = SHADER_SW;
/* set the state of the device to valid */ /* set the state of the device to valid */
object->state = WINED3D_OK; object->state = WINED3D_OK;
......
...@@ -132,12 +132,20 @@ WINED3DGLTYPE static const glTypeLookup[D3DDECLTYPE_UNUSED] = { ...@@ -132,12 +132,20 @@ WINED3DGLTYPE static const glTypeLookup[D3DDECLTYPE_UNUSED] = {
#define NP2_NONE 0 #define NP2_NONE 0
#define NP2_REPACK 1 #define NP2_REPACK 1
#define SHADER_SW 0
#define SHADER_ARB 1
#define SHADER_GLSL 2
typedef struct wined3d_settings_s { typedef struct wined3d_settings_s {
/* vertex and pixel shader modes */ /* vertex and pixel shader modes */
int vs_mode; int vs_mode;
int ps_mode; int ps_mode;
int vbo_mode; int vbo_mode;
/* Ideally, we don't want the user to have to request GLSL. If the hardware supports GLSL,
we should use it. However, until it's fully implemented, we'll leave it as a registry
setting for developers. */
BOOL glslRequested; BOOL glslRequested;
int shader_mode;
/* nonpower 2 function */ /* nonpower 2 function */
int nonpower2_mode; int nonpower2_mode;
} wined3d_settings_t; } wined3d_settings_t;
...@@ -1273,13 +1281,6 @@ struct SHADER_OPCODE_ARG; ...@@ -1273,13 +1281,6 @@ struct SHADER_OPCODE_ARG;
typedef void (*shader_fct_t)(); typedef void (*shader_fct_t)();
typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*); typedef void (*SHADER_HANDLER) (struct SHADER_OPCODE_ARG*);
/* This must be 0 in the main branch until GLSL is at least mostly implemented.
Also, think about making it a winecfg option to use GLSL (if the card supports it)
or ARB_vertex_program. Ideally, we want to use GLSL if it's available, but until
everything is implemented, we'll probably have better luck with the ARB generation */
#define USING_GLSL 0
#define SHADER_PGMSIZE 65535 #define SHADER_PGMSIZE 65535
typedef struct SHADER_BUFFER { typedef struct SHADER_BUFFER {
char* buffer; char* buffer;
......
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