Jason Green : wined3d: Further split GLSL & ARB_v/
f_program generation and allow GLSL functions to be called.
Alexandre Julliard
julliard at wine.codeweavers.com
Wed May 10 05:22:59 CDT 2006
Module: wine
Branch: refs/heads/master
Commit: e9927d6ffd9c6865936520453c74e2cd680edc7a
URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=e9927d6ffd9c6865936520453c74e2cd680edc7a
Author: Jason Green <jave27 at gmail.com>
Date: Tue May 9 22:47:35 2006 -0400
wined3d: Further split GLSL & ARB_v/f_program generation and allow GLSL functions to be called.
---
dlls/wined3d/baseshader.c | 83 ++++++++++++++++++++++++++++------------
dlls/wined3d/wined3d_private.h | 7 +++
2 files changed, 65 insertions(+), 25 deletions(-)
diff --git a/dlls/wined3d/baseshader.c b/dlls/wined3d/baseshader.c
index f1929d6..5c3b143 100644
--- a/dlls/wined3d/baseshader.c
+++ b/dlls/wined3d/baseshader.c
@@ -238,6 +238,43 @@ void shader_program_dump_decl_usage(
}
}
+/** Generate the variable & register declarations for the ARB_vertex_program
+ output target */
+void generate_arb_declarations(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer) {
+
+ IWineD3DBaseShaderImpl* This = (IWineD3DBaseShaderImpl*) iface;
+ DWORD i;
+
+ for(i = 0; i < This->baseShader.limits.temporary; i++) {
+ if (This->baseShader.temps_used & (1 << i))
+ shader_addline(buffer, "TEMP R%lu;\n", i);
+ }
+
+ for (i = 0; i < This->baseShader.limits.address; i++) {
+ if (This->baseShader.textures_used & (1 << i))
+ shader_addline(buffer, "ADDRESS A%ld;\n", i);
+ }
+
+ for(i = 0; i < This->baseShader.limits.texture; i++) {
+ if (This->baseShader.textures_used & (1 << i))
+ shader_addline(buffer,"TEMP T%lu;\n", i);
+ }
+
+ /* Texture coordinate registers must be pre-loaded */
+ for (i = 0; i < This->baseShader.limits.texture; i++) {
+ if (This->baseShader.textures_used & (1 << i))
+ shader_addline(buffer, "MOV T%lu, fragment.texcoord[%lu];\n", i, i);
+ }
+}
+
+/** Generate the variable & register declarations for the GLSL
+ output target */
+void generate_glsl_declarations(IWineD3DBaseShader *iface, SHADER_BUFFER* buffer) {
+
+ FIXME("GLSL not fully implemented yet.\n");
+
+}
+
/** Shared code in order to generate the bulk of the shader string.
Use the shader_header_fct & shader_footer_fct to add strings
that are specific to pixel or vertex functions
@@ -267,26 +304,10 @@ void generate_base_shader(
*/
/* Pre-declare registers */
- for(i = 0; i < This->baseShader.limits.temporary; i++) {
- if (This->baseShader.temps_used & (1 << i))
- shader_addline(buffer, "TEMP R%lu;\n", i);
- }
-
- for (i = 0; i < This->baseShader.limits.address; i++) {
- if (This->baseShader.textures_used & (1 << i))
- shader_addline(buffer, "ADDRESS A%ld;\n", i);
- }
-
- for(i = 0; i < This->baseShader.limits.texture; i++) {
- if (This->baseShader.textures_used & (1 << i))
- shader_addline(buffer,"TEMP T%lu;\n", i);
- }
-
- /* Texture coordinate registers must be pre-loaded */
- for (i = 0; i < This->baseShader.limits.texture; i++) {
- if (This->baseShader.textures_used & (1 << i))
- shader_addline(buffer, "MOV T%lu, fragment.texcoord[%lu];\n", i, i);
- }
+ if (USING_GLSL)
+ generate_glsl_declarations(iface, buffer);
+ else
+ generate_arb_declarations(iface, buffer);
/* Second pass, process opcodes */
if (NULL != pToken) {
@@ -318,15 +339,22 @@ void generate_base_shader(
++pToken;
}
- /* Unhandled opcode */
- } else if (GLNAME_REQUIRE_GLSL == curOpcode->glname) {
+ /* Using GLSL & no generator function exists */
+ } else if (USING_GLSL && curOpcode->hw_glsl_fct == NULL) {
+
+ FIXME("Token %s is not yet implemented with GLSL\n", curOpcode->name);
+ pToken += curOpcode->num_params;
+
+ /* Unhandled opcode in ARB */
+ } else if ( !USING_GLSL && GLNAME_REQUIRE_GLSL == curOpcode->glname) {
FIXME("Token %s requires greater functionality than "
"Vertex or Fragment_Program_ARB supports\n", curOpcode->name);
pToken += curOpcode->num_params;
- /* If a generator function is set, use it */
- } else if (curOpcode->hw_fct != NULL) {
+ /* If a generator function is set for current shader target, use it */
+ } else if ((!USING_GLSL && curOpcode->hw_fct != NULL) ||
+ (USING_GLSL && curOpcode->hw_glsl_fct != NULL)) {
SHADER_OPCODE_ARG hw_arg;
@@ -341,7 +369,12 @@ void generate_base_shader(
hw_arg.src[i-1] = *(pToken + i);
}
- curOpcode->hw_fct(&hw_arg);
+ /* Call appropriate function for output target */
+ if (USING_GLSL)
+ curOpcode->hw_glsl_fct(&hw_arg);
+ else
+ curOpcode->hw_fct(&hw_arg);
+
pToken += curOpcode->num_params;
} else {
diff --git a/dlls/wined3d/wined3d_private.h b/dlls/wined3d/wined3d_private.h
index 137cb1a..30cf91c 100644
--- a/dlls/wined3d/wined3d_private.h
+++ b/dlls/wined3d/wined3d_private.h
@@ -1201,6 +1201,13 @@ 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;
More information about the wine-cvs
mailing list