Changeset 59741 in vbox for trunk/src/VBox/Devices/Graphics/shaderlib
- Timestamp:
- Feb 19, 2016 3:11:35 PM (9 years ago)
- svn:sync-xref-src-repo-rev:
- 105608
- Location:
- trunk/src/VBox/Devices/Graphics/shaderlib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Graphics/shaderlib/glsl_shader.c
r54765 r59741 4262 4262 } 4263 4263 4264 #ifdef VBOX_WITH_VMSVGA 4265 static GLhandleARB generate_passthrough_vshader(const struct wined3d_gl_info *gl_info) 4266 { 4267 GLhandleARB ret = 0; 4268 static const char *passthrough_vshader[] = 4269 { 4270 "#version 120\n" 4271 "vec4 R0;\n" 4272 "void main(void)\n" 4273 "{\n" 4274 " R0 = gl_Vertex;\n" 4275 " R0.w = 1.0;\n" 4276 " R0.z = 0.0;\n" 4277 " gl_Position = gl_ModelViewProjectionMatrix * R0;\n" 4278 "}\n" 4279 }; 4280 4281 ret = GL_EXTCALL(glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)); 4282 checkGLcall("glCreateShaderObjectARB(GL_VERTEX_SHADER_ARB)"); 4283 GL_EXTCALL(glShaderSourceARB(ret, 1, passthrough_vshader, NULL)); 4284 checkGLcall("glShaderSourceARB(ret, 1, passthrough_vshader, NULL)"); 4285 GL_EXTCALL(glCompileShaderARB(ret)); 4286 checkGLcall("glCompileShaderARB(ret)"); 4287 shader_glsl_validate_compile_link(gl_info, ret, FALSE); 4288 4289 return ret; 4290 } 4291 4292 #endif 4293 4264 4294 /* GL locking is done by the caller */ 4265 4295 static void hardcode_local_constants(IWineD3DBaseShaderImpl *shader, const struct wined3d_gl_info *gl_info, … … 4710 4740 list_add_head(&((IWineD3DBaseShaderImpl *)vshader)->baseShader.linked_programs, &entry->vshader_entry); 4711 4741 } 4742 #ifdef VBOX_WITH_VMSVGA 4743 else 4744 if (device->strided_streams.position_transformed) 4745 { 4746 GLhandleARB passthrough_vshader_id; 4747 4748 passthrough_vshader_id = generate_passthrough_vshader(gl_info); 4749 TRACE("Attaching GLSL shader object %p to program %p\n", (void *)(uintptr_t)passthrough_vshader_id, (void *)(uintptr_t)programId); 4750 GL_EXTCALL(glAttachObjectARB(programId, passthrough_vshader_id)); 4751 checkGLcall("glAttachObjectARB"); 4752 /* Flag the reorder function for deletion, then it will be freed automatically when the program 4753 * is destroyed 4754 */ 4755 GL_EXTCALL(glDeleteObjectARB(passthrough_vshader_id)); 4756 } 4757 #endif 4758 4712 4759 4713 4760 /* Attach GLSL pshader */ -
trunk/src/VBox/Devices/Graphics/shaderlib/shaderapi.c
r53755 r59741 15 15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind. 16 16 */ 17 18 17 #include <iprt/err.h> 19 18 #include <iprt/mem.h> … … 626 625 } 627 626 627 SHADERDECL(int) ShaderSetPositionTransformed(void *pShaderContext, unsigned cxViewPort, unsigned cyViewPort, bool fPreTransformed) 628 { 629 IWineD3DDeviceImpl *This; 630 int rc; 631 632 SHADER_SET_CURRENT_CONTEXT(pShaderContext); 633 This = g_pCurrentContext->pDeviceContext; 634 635 if (This->strided_streams.position_transformed == fPreTransformed) 636 return VINF_SUCCESS; /* no changes; nothing to do. */ 637 638 Log(("ShaderSetPositionTransformed viewport (%d,%d) fPreTransformed=%d\n", cxViewPort, cyViewPort, fPreTransformed)); 639 640 if (fPreTransformed) 641 { /* In the pre-transformed vertex coordinate case we need to disable all transformations as we're already using screen coordinates. */ 642 /* Load the identity matrix for the model view */ 643 glMatrixMode(GL_MODELVIEW); 644 glLoadIdentity(); 645 646 /* Reset the projection matrix too */ 647 rc = ShaderTransformProjection(cxViewPort, cyViewPort, NULL, fPreTransformed); 648 AssertRCReturn(rc, rc); 649 } 650 651 This->strided_streams.position_transformed = fPreTransformed; 652 ((IWineD3DVertexDeclarationImpl *)(This->stateBlock->vertexDecl))->position_transformed = fPreTransformed; 653 return VINF_SUCCESS; 654 } 655 628 656 SHADERDECL(int) ShaderUpdateState(void *pShaderContext, uint32_t rtHeight) 629 657 { … … 668 696 } 669 697 670 SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16] )698 SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16], bool fPretransformed) 671 699 { 672 700 #ifdef DEBUG … … 723 751 724 752 glTranslatef(xoffset, -yoffset, -1.0f); 725 /* flip y coordinate origin too */ 726 glScalef(1.0f, -1.0f, 2.0f); 727 728 glMultMatrixf(matrix); 729 753 754 if (fPretransformed) 755 { 756 /* One world coordinate equals one screen pixel; y-inversion no longer an issue */ 757 glOrtho(0, cxViewPort, 0, cyViewPort, -1, 1); 758 } 759 else 760 { 761 /* flip y coordinate origin too */ 762 glScalef(1.0f, -1.0f, 2.0f); 763 764 /* Apply the supplied projection matrix */ 765 glMultMatrixf(matrix); 766 } 730 767 #ifdef DEBUG 731 768 lastError = glGetError(); \ -
trunk/src/VBox/Devices/Graphics/shaderlib/shaderlib.h
r53755 r59741 87 87 SHADERDECL(int) ShaderSetPixelShaderConstantF(void *pShaderContext, uint32_t reg, const float *pValues, uint32_t cRegisters); 88 88 89 SHADERDECL(int) ShaderSetPositionTransformed(void *pShaderContext, unsigned cxViewPort, unsigned cyViewPort, bool fPreTransformed); 90 89 91 SHADERDECL(int) ShaderUpdateState(void *pShaderContext, uint32_t rtHeight); 90 92 91 SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16] );93 SHADERDECL(int) ShaderTransformProjection(unsigned cxViewPort, unsigned cyViewPort, float matrix[16], bool fPretransformed); 92 94 93 95 RT_C_DECLS_END
Note:
See TracChangeset
for help on using the changeset viewer.