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

This commit is contained in:
Jason Green 2006-05-23 18:22:59 -04:00 committed by Alexandre Julliard
parent a67488a26e
commit d204540d1f
3 changed files with 32 additions and 16 deletions

View File

@ -583,7 +583,7 @@ void generate_base_shader(
*/
/* Pre-declare registers */
if (USING_GLSL) {
if (wined3d_settings.shader_mode == SHADER_GLSL) {
generate_glsl_declarations(iface, &reg_maps, buffer);
shader_addline(buffer, "void main() {\n");
} else {
@ -612,7 +612,8 @@ void generate_base_shader(
/* Read opcode */
opcode_token = *pToken++;
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 */
if (NULL == curOpcode) {
@ -692,7 +693,7 @@ void print_glsl_info_log(
{
infoLog = (char *)HeapAlloc(GetProcessHeap(), 0, infologLength);
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);
}
}

View File

@ -1693,11 +1693,13 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D
*pCaps->MaxStreams = MAX_STREAMS;
*pCaps->MaxStreamStride = 1024;
if (wined3d_settings.vs_mode == VS_HW && GL_SUPPORT(ARB_SHADING_LANGUAGE_100) &&
wined3d_settings.glslRequested && DeviceType != WINED3DDEVTYPE_REF) {
if (wined3d_settings.vs_mode == VS_HW && wined3d_settings.shader_mode == SHADER_GLSL
&& DeviceType != WINED3DDEVTYPE_REF) {
*pCaps->VertexShaderVersion = D3DVS_VERSION(3,0);
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);
TRACE_(d3d_caps)("Hardware vertex shader version 1.1 enabled\n");
} else if (wined3d_settings.vs_mode == VS_SW || DeviceType == WINED3DDEVTYPE_REF) {
@ -1715,13 +1717,15 @@ HRESULT WINAPI IWineD3DImpl_GetDeviceCaps(IWineD3D *iface, UINT Adapter, WINED3D
*pCaps->MaxVertexShaderConst = WINED3D_VSHADER_MAX_CONSTANTS;
}
if (wined3d_settings.ps_mode == PS_HW && GL_SUPPORT(ARB_SHADING_LANGUAGE_100) &&
wined3d_settings.glslRequested && DeviceType != WINED3DDEVTYPE_REF) {
if (wined3d_settings.ps_mode == PS_HW && wined3d_settings.shader_mode == SHADER_GLSL
&& DeviceType != WINED3DDEVTYPE_REF) {
*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 */
*pCaps->PixelShader1xMaxValue = 1.0;
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->PixelShader1xMaxValue = 1.0;
TRACE_(d3d_caps)("Hardware pixel shader version 1.4 enabled\n");
@ -1839,6 +1843,16 @@ HRESULT WINAPI IWineD3DImpl_CreateDevice(IWineD3D *iface, UINT Adapter, WINED3
IWineD3DImpl_FillGLCaps(&This->gl_info, IWineD3DImpl_GetAdapterDisplay(iface, Adapter));
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 */
object->state = WINED3D_OK;

View File

@ -132,12 +132,20 @@ WINED3DGLTYPE static const glTypeLookup[D3DDECLTYPE_UNUSED] = {
#define NP2_NONE 0
#define NP2_REPACK 1
#define SHADER_SW 0
#define SHADER_ARB 1
#define SHADER_GLSL 2
typedef struct wined3d_settings_s {
/* vertex and pixel shader modes */
int vs_mode;
int ps_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;
int shader_mode;
/* nonpower 2 function */
int nonpower2_mode;
} wined3d_settings_t;
@ -1273,13 +1281,6 @@ struct SHADER_OPCODE_ARG;
typedef void (*shader_fct_t)();
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
typedef struct SHADER_BUFFER {
char* buffer;