Module: wine Branch: refs/heads/master Commit: 68f75555d3dd213a5af8c1909828868b214e176c URL: http://source.winehq.org/git/?p=wine.git;a=commit;h=68f75555d3dd213a5af8c190...
Author: Jason Green jave27@gmail.com Date: Tue May 9 22:39:39 2006 -0400
wined3d: Use GenerateShader in pixel shaders and remove old function.
---
dlls/wined3d/pixelshader.c | 191 -------------------------------------------- 1 files changed, 1 insertions(+), 190 deletions(-)
diff --git a/dlls/wined3d/pixelshader.c b/dlls/wined3d/pixelshader.c index 6e0c126..c63825f 100644 --- a/dlls/wined3d/pixelshader.c +++ b/dlls/wined3d/pixelshader.c @@ -1370,195 +1370,6 @@ #if 1 /* if were using the data buffer o #endif }
-/* NOTE: A description of how to parse tokens can be found at http://msdn.microsoft.com/library/default.asp?url=/library/en-us/graphics/hh... */ -inline static VOID IWineD3DPixelShaderImpl_GenerateProgramArbHW(IWineD3DPixelShader *iface, CONST DWORD *pFunction) { - IWineD3DPixelShaderImpl *This = (IWineD3DPixelShaderImpl *)iface; - const DWORD *pToken = pFunction; - const SHADER_OPCODE *curOpcode = NULL; - DWORD i; - SHADER_BUFFER buffer; - - /* Keep bitmaps of used temporary and texture registers */ - DWORD tempsUsed, texUsed; - - /* Initialize current parsing state */ - This->baseShader.parse_state.current_row = 0; - -#if 0 /* FIXME: Use the buffer that is held by the device, this is ok since fixups will be skipped for software shaders - it also requires entering a critical section but cuts down the runtime footprint of wined3d and any memory fragmentation that may occur... */ - if (This->device->fixupVertexBufferSize < SHADER_PGMSIZE) { - HeapFree(GetProcessHeap(), 0, This->fixupVertexBuffer); - This->fixupVertexBuffer = HeapAlloc(GetProcessHeap() , 0, SHADER_PGMSIZE); - This->fixupVertexBufferSize = SHADER_PGMSIZE; - This->fixupVertexBuffer[0] = 0; - } - buffer.buffer = This->device->fixupVertexBuffer; -#else - buffer.buffer = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, SHADER_PGMSIZE); -#endif - buffer.bsize = 0; - buffer.lineNo = 0; - - /* FIXME: if jumps are used, use GLSL, else use ARB_fragment_program */ - shader_addline(&buffer, "!!ARBfp1.0\n"); - - /* TODO: Think about using a first pass to work out what's required for the second pass. */ - for(i = 0; i < WINED3D_PSHADER_MAX_CONSTANTS; i++) - This->constants[i] = 0; - - /* First pass: figure out which temporary and texture registers are used */ - shader_get_registers_used((IWineD3DBaseShader*) This, pToken); - texUsed = This->baseShader.textures_used; - tempsUsed = This->baseShader.temps_used; - - TRACE("Texture registers used: %#lx, Temp registers used %#lx\n", texUsed, tempsUsed); - - /* TODO: check register usage against GL/Directx limits, and fail if they're exceeded */ - - /* Pre-declare registers */ - for(i = 0; i < This->baseShader.limits.texture; i++) { - if (texUsed & (1 << i)) - shader_addline(&buffer,"TEMP T%lu;\n", i); - } - - for(i = 0; i < This->baseShader.limits.temporary; i++) { - if (tempsUsed & (1 << i)) - shader_addline(&buffer, "TEMP R%lu;\n", i); - } - - /* Necessary for internal operations */ - shader_addline(&buffer, "TEMP TMP;\n"); - shader_addline(&buffer, "TEMP TMP2;\n"); - shader_addline(&buffer, "TEMP TA;\n"); - shader_addline(&buffer, "TEMP TB;\n"); - shader_addline(&buffer, "TEMP TC;\n"); - shader_addline(&buffer, "PARAM coefdiv = { 0.5, 0.25, 0.125, 0.0625 };\n"); - shader_addline(&buffer, "PARAM coefmul = { 2, 4, 8, 16 };\n"); - shader_addline(&buffer, "PARAM one = { 1.0, 1.0, 1.0, 1.0 };\n"); - - /* Texture coordinate registers must be pre-loaded */ - for (i = 0; i < This->baseShader.limits.texture; i++) { - if (texUsed & (1 << i)) - shader_addline(&buffer, "MOV T%lu, fragment.texcoord[%lu];\n", i, i); - } - - /* Second pass, process opcodes */ - if (NULL != pToken) { - while (D3DPS_END() != *pToken) { -#if 0 /* For pixel and vertex shader versions 2_0 and later, bits 24 through 27 specify the size in DWORDs of the instruction */ - if (version >= 2) { - instructionSize = pToken & SIZEBITS >> 27; - } -#endif - - /* Skip version token */ - if (pshader_is_version_token(*pToken)) { - ++pToken; - continue; - } - - /* Skip comment tokens */ - if (pshader_is_comment_token(*pToken)) { - DWORD comment_len = (*pToken & D3DSI_COMMENTSIZE_MASK) >> D3DSI_COMMENTSIZE_SHIFT; - ++pToken; - TRACE("#%s\n", (char*)pToken); - pToken += comment_len; - continue; - } - - /* Read opcode */ - curOpcode = shader_get_opcode((IWineD3DBaseShader*) This, *pToken); - ++pToken; - - /* Unknown opcode and its parameters */ - if (NULL == curOpcode) { - while (*pToken & 0x80000000) { /* TODO: Think of a sensible name for 0x80000000 */ - FIXME("unrecognized opcode: %08lx\n", *pToken); - ++pToken; - } - - /* Unhandled opcode */ - } else if (GLNAME_REQUIRE_GLSL == curOpcode->glname) { - - FIXME("Token %s requires greater functionality than " - "Fragment_Progarm_ARB supports\n", curOpcode->name); - pToken += curOpcode->num_params; - - /* If a generator function is set, use it */ - } else if (curOpcode->hw_fct != NULL) { - - SHADER_OPCODE_ARG hw_arg; - - hw_arg.shader = (IWineD3DBaseShader*) This; - hw_arg.opcode = curOpcode; - hw_arg.buffer = &buffer; - if (curOpcode->num_params > 0) { - hw_arg.dst = *pToken; - - /* FIXME: this does not account for relative address tokens */ - for (i = 1; i < curOpcode->num_params; i++) - hw_arg.src[i-1] = *(pToken + i); - } - - curOpcode->hw_fct(&hw_arg); - pToken += curOpcode->num_params; - - } else { - - TRACE("Found opcode D3D:%s GL:%s, PARAMS:%d, \n", - curOpcode->name, curOpcode->glname, curOpcode->num_params); - - /* Build opcode for GL vertex_program */ - switch (curOpcode->opcode) { - case D3DSIO_NOP: - break; - - default: - FIXME("Can't handle opcode %s in hwShader\n", curOpcode->name); - pToken += curOpcode->num_params; - } - } - } - /* TODO: What about result.depth? */ - shader_addline(&buffer, "MOV result.color, R0;\n"); - shader_addline(&buffer, "END\n"); - } - - /* finally null terminate the buffer */ - buffer.buffer[buffer.bsize] = 0; - if (GL_SUPPORT(ARB_VERTEX_PROGRAM)) { - /* Create the hw shader */ - - /* The program string sometimes gets too long for a normal TRACE */ - TRACE("Generated program:\n"); - if (TRACE_ON(d3d_shader)) { - fprintf(stderr, "%s\n", buffer.buffer); - } - - /* TODO: change to resource.glObjectHandel or something like that */ - GL_EXTCALL(glGenProgramsARB(1, &This->baseShader.prgId)); - - TRACE("Creating a hw pixel shader, prg=%d\n", This->baseShader.prgId); - GL_EXTCALL(glBindProgramARB(GL_FRAGMENT_PROGRAM_ARB, This->baseShader.prgId)); - - TRACE("Created hw pixel shader, prg=%d\n", This->baseShader.prgId); - /* Create the program and check for errors */ - GL_EXTCALL(glProgramStringARB(GL_FRAGMENT_PROGRAM_ARB, GL_PROGRAM_FORMAT_ASCII_ARB, - buffer.bsize, buffer.buffer)); - - if (glGetError() == GL_INVALID_OPERATION) { - GLint errPos; - glGetIntegerv(GL_PROGRAM_ERROR_POSITION_ARB, &errPos); - FIXME("HW PixelShader Error at position %d: %s\n", - errPos, debugstr_a((const char *)glGetString(GL_PROGRAM_ERROR_STRING_ARB))); - This->baseShader.prgId = -1; - } - } -#if 1 /* if were using the data buffer of device then we don't need to free it */ - HeapFree(GetProcessHeap(), 0, buffer.buffer); -#endif -} - inline static void pshader_program_dump_ins_modifiers(const DWORD output) {
DWORD shift = (output & D3DSP_DSTSHIFT_MASK) >> D3DSP_DSTSHIFT_SHIFT; @@ -1808,7 +1619,7 @@ HRESULT WINAPI IWineD3DPixelShaderImpl_S if (NULL != pFunction && wined3d_settings.vs_mode == VS_HW) { TRACE("(%p) : Generating hardware program\n", This); #if 1 - IWineD3DPixelShaderImpl_GenerateProgramArbHW(iface, pFunction); + IWineD3DPixelShaderImpl_GenerateShader(iface, pFunction); #endif }