wined3d: Further split GLSL & ARB_v/f_program generation and allow GLSL functions to be called.
This commit is contained in:
parent
246677ae46
commit
e9927d6ffd
|
@ -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.
|
/** Shared code in order to generate the bulk of the shader string.
|
||||||
Use the shader_header_fct & shader_footer_fct to add strings
|
Use the shader_header_fct & shader_footer_fct to add strings
|
||||||
that are specific to pixel or vertex functions
|
that are specific to pixel or vertex functions
|
||||||
|
@ -267,26 +304,10 @@ void generate_base_shader(
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Pre-declare registers */
|
/* Pre-declare registers */
|
||||||
for(i = 0; i < This->baseShader.limits.temporary; i++) {
|
if (USING_GLSL)
|
||||||
if (This->baseShader.temps_used & (1 << i))
|
generate_glsl_declarations(iface, buffer);
|
||||||
shader_addline(buffer, "TEMP R%lu;\n", i);
|
else
|
||||||
}
|
generate_arb_declarations(iface, buffer);
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Second pass, process opcodes */
|
/* Second pass, process opcodes */
|
||||||
if (NULL != pToken) {
|
if (NULL != pToken) {
|
||||||
|
@ -318,15 +339,22 @@ void generate_base_shader(
|
||||||
++pToken;
|
++pToken;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Unhandled opcode */
|
/* Using GLSL & no generator function exists */
|
||||||
} else if (GLNAME_REQUIRE_GLSL == curOpcode->glname) {
|
} 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 "
|
FIXME("Token %s requires greater functionality than "
|
||||||
"Vertex or Fragment_Program_ARB supports\n", curOpcode->name);
|
"Vertex or Fragment_Program_ARB supports\n", curOpcode->name);
|
||||||
pToken += curOpcode->num_params;
|
pToken += curOpcode->num_params;
|
||||||
|
|
||||||
/* If a generator function is set, use it */
|
/* If a generator function is set for current shader target, use it */
|
||||||
} else if (curOpcode->hw_fct != NULL) {
|
} else if ((!USING_GLSL && curOpcode->hw_fct != NULL) ||
|
||||||
|
(USING_GLSL && curOpcode->hw_glsl_fct != NULL)) {
|
||||||
|
|
||||||
SHADER_OPCODE_ARG hw_arg;
|
SHADER_OPCODE_ARG hw_arg;
|
||||||
|
|
||||||
|
@ -341,7 +369,12 @@ void generate_base_shader(
|
||||||
hw_arg.src[i-1] = *(pToken + i);
|
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;
|
pToken += curOpcode->num_params;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1201,6 +1201,13 @@ 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;
|
||||||
|
|
Loading…
Reference in New Issue