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

wined3d: Give the nvts/nvrc code its own pipeline implementation.

This code creates the structures and the pipeline selection, as well as the caps filling. It does not yet move the actual code around, since this will be a bigger task.
parent 7c216b8a
...@@ -19,6 +19,7 @@ C_SRCS = \ ...@@ -19,6 +19,7 @@ C_SRCS = \
drawprim.c \ drawprim.c \
glsl_shader.c \ glsl_shader.c \
indexbuffer.c \ indexbuffer.c \
nvidia_texture_shader.c \
palette.c \ palette.c \
pixelshader.c \ pixelshader.c \
query.c \ query.c \
......
...@@ -2894,8 +2894,13 @@ static const struct fragment_pipeline *select_fragment_implementation(UINT Adapt ...@@ -2894,8 +2894,13 @@ static const struct fragment_pipeline *select_fragment_implementation(UINT Adapt
select_shader_mode(&GLINFO_LOCATION, DeviceType, &ps_selected_mode, &vs_selected_mode); select_shader_mode(&GLINFO_LOCATION, DeviceType, &ps_selected_mode, &vs_selected_mode);
if(ps_selected_mode == SHADER_ATI) { if(ps_selected_mode == SHADER_ATI) {
return &atifs_fragment_pipeline; return &atifs_fragment_pipeline;
} else if(GL_SUPPORT(NV_REGISTER_COMBINERS) && GL_SUPPORT(NV_TEXTURE_SHADER2)) {
return &nvts_fragment_pipeline;
} else if(GL_SUPPORT(NV_REGISTER_COMBINERS)) {
return &nvrc_fragment_pipeline;
} else {
return &ffp_fragment_pipeline;
} }
return &ffp_fragment_pipeline;
} }
/* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true /* Note: d3d8 passes in a pointer to a D3DCAPS8 structure, which is a true
......
/*
* Fixed function pipeline replacement using GL_NV_register_combiners
* and GL_NV_texture_shader
*
* Copyright 2006 Henri Verbeet
* Copyright 2008 Stefan Dsinger(for CodeWeavers)
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include <math.h>
#include <stdio.h>
#include "wined3d_private.h"
WINE_DEFAULT_DEBUG_CHANNEL(d3d);
#define GLINFO_LOCATION (*gl_info)
static void nvrc_enable(IWineD3DDevice *iface, BOOL enable) { }
static void nvts_enable(IWineD3DDevice *iface, BOOL enable) {
if(enable) {
glEnable(GL_TEXTURE_SHADER_NV);
checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");
} else {
glDisable(GL_TEXTURE_SHADER_NV);
checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");
}
}
static void nvrc_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
WINED3DTEXOPCAPS_ADDSIGNED |
WINED3DTEXOPCAPS_ADDSIGNED2X |
WINED3DTEXOPCAPS_MODULATE |
WINED3DTEXOPCAPS_MODULATE2X |
WINED3DTEXOPCAPS_MODULATE4X |
WINED3DTEXOPCAPS_SELECTARG1 |
WINED3DTEXOPCAPS_SELECTARG2 |
WINED3DTEXOPCAPS_DISABLE |
WINED3DTEXOPCAPS_BLENDDIFFUSEALPHA |
WINED3DTEXOPCAPS_BLENDTEXTUREALPHA |
WINED3DTEXOPCAPS_BLENDFACTORALPHA |
WINED3DTEXOPCAPS_BLENDCURRENTALPHA |
WINED3DTEXOPCAPS_LERP |
WINED3DTEXOPCAPS_SUBTRACT |
WINED3DTEXOPCAPS_ADDSMOOTH |
WINED3DTEXOPCAPS_MULTIPLYADD |
WINED3DTEXOPCAPS_MODULATEALPHA_ADDCOLOR |
WINED3DTEXOPCAPS_MODULATECOLOR_ADDALPHA |
WINED3DTEXOPCAPS_BLENDTEXTUREALPHAPM |
WINED3DTEXOPCAPS_DOTPRODUCT3 |
WINED3DTEXOPCAPS_MODULATEINVALPHA_ADDCOLOR |
WINED3DTEXOPCAPS_MODULATEINVCOLOR_ADDALPHA;
if(GL_SUPPORT(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
* shaders constantly enabled.
*/
pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAP;
/* TODO: Luminance bump map? */
}
#if 0
/* FIXME: Add
pCaps->TextureOpCaps |= WINED3DTEXOPCAPS_BUMPENVMAPLUMINANCE
WINED3DTEXOPCAPS_PREMODULATE */
#endif
pCaps->MaxTextureBlendStages = GL_LIMITS(texture_stages);
pCaps->MaxSimultaneousTextures = GL_LIMITS(textures);
pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_TSSARGTEMP;
/* 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))
pCaps->PrimitiveMiscCaps |= WINED3DPMISCCAPS_PERSTAGECONSTANT;
#endif
}
static HRESULT nvrc_fragment_alloc(IWineD3DDevice *iface) { return WINED3D_OK; }
static void nvrc_fragment_free(IWineD3DDevice *iface) {}
/* Two fixed function pipeline implementations using GL_NV_register_combiners and
* GL_NV_texture_shader. The nvts_fragment_pipeline assumes that both extensions
* are available(geforce 3 and newer), while nvrc_fragment_pipeline uses only the
* register combiners extension(Pre-GF3).
*/
const struct fragment_pipeline nvts_fragment_pipeline = {
nvts_enable,
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
ffp_fragmentstate_template
};
const struct fragment_pipeline nvrc_fragment_pipeline = {
nvrc_enable,
nvrc_fragment_get_caps,
nvrc_fragment_alloc,
nvrc_fragment_free,
ffp_fragmentstate_template
};
...@@ -4311,7 +4311,7 @@ const struct StateEntryTemplate ffp_vertexstate_template[] = { ...@@ -4311,7 +4311,7 @@ const struct StateEntryTemplate ffp_vertexstate_template[] = {
{0 /* Terminate */, { 0, 0 }}, {0 /* Terminate */, { 0, 0 }},
}; };
static const struct StateEntryTemplate ffp_fragmentstate_template[] = { const struct StateEntryTemplate ffp_fragmentstate_template[] = {
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }}, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }},
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }}, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG1), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }},
{ STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }}, { STATE_TEXTURESTAGE(0, WINED3DTSS_COLORARG2), { STATE_TEXTURESTAGE(0, WINED3DTSS_COLOROP), tex_colorop }},
...@@ -4465,20 +4465,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = { ...@@ -4465,20 +4465,7 @@ static const struct StateEntryTemplate ffp_fragmentstate_template[] = {
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
#define GLINFO_LOCATION (*gl_info) #define GLINFO_LOCATION (*gl_info)
static void nvts_enable(IWineD3DDevice *iface, BOOL enable) { static void ffp_enable(IWineD3DDevice *iface, BOOL enable) { }
IWineD3DDeviceImpl *This = (IWineD3DDeviceImpl *) iface;
WineD3D_GL_Info *gl_info = &This->adapter->gl_info;
if(GL_SUPPORT(NV_TEXTURE_SHADER2)) {
if(enable) {
glEnable(GL_TEXTURE_SHADER_NV);
checkGLcall("glEnable(GL_TEXTURE_SHADER_NV)");
} else {
glDisable(GL_TEXTURE_SHADER_NV);
checkGLcall("glDisable(GL_TEXTURE_SHADER_NV)");
}
}
}
static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) { static void ffp_fragment_get_caps(WINED3DDEVTYPE devtype, WineD3D_GL_Info *gl_info, struct fragment_caps *pCaps) {
pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD | pCaps->TextureOpCaps = WINED3DTEXOPCAPS_ADD |
...@@ -4556,7 +4543,7 @@ static void ffp_fragment_free(IWineD3DDevice *iface) {} ...@@ -4556,7 +4543,7 @@ static void ffp_fragment_free(IWineD3DDevice *iface) {}
#undef GLINFO_LOCATION #undef GLINFO_LOCATION
const struct fragment_pipeline ffp_fragment_pipeline = { const struct fragment_pipeline ffp_fragment_pipeline = {
nvts_enable, ffp_enable,
ffp_fragment_get_caps, ffp_fragment_get_caps,
ffp_fragment_alloc, ffp_fragment_alloc,
ffp_fragment_free, ffp_fragment_free,
......
...@@ -560,6 +560,10 @@ extern const struct StateEntryTemplate misc_state_template[]; ...@@ -560,6 +560,10 @@ extern const struct StateEntryTemplate misc_state_template[];
extern const struct StateEntryTemplate ffp_vertexstate_template[]; extern const struct StateEntryTemplate ffp_vertexstate_template[];
extern const struct fragment_pipeline ffp_fragment_pipeline; extern const struct fragment_pipeline ffp_fragment_pipeline;
extern const struct fragment_pipeline atifs_fragment_pipeline; extern const struct fragment_pipeline atifs_fragment_pipeline;
extern const struct fragment_pipeline nvts_fragment_pipeline;
extern const struct fragment_pipeline nvrc_fragment_pipeline;
extern const struct StateEntryTemplate ffp_fragmentstate_template[]; /* temporary */
/* "Base" state table */ /* "Base" state table */
void compile_state_table(struct StateEntry *StateTable, void compile_state_table(struct StateEntry *StateTable,
......
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