Module: wine
Branch: master
Commit: 81aeae32497822302e43bc5a3e31b22cbb9ec0e8
URL: http://source.winehq.org/git/wine.git/?a=commit;h=81aeae32497822302e43bc5a3…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Tue Mar 6 14:56:58 2007 +0100
wined3d: Do not specify the viewport origin upside down when doing offscreen rendering.
The gl viewport origin is the lower left corner of the window, in d3d
it is the upper right corner. This is corrected when setting the
viewport. However, when we are doing offscreen rendering, this is
reversed. So do not flip the viewport origin when rendering offscreen.
---
dlls/wined3d/device.c | 4 ++++
dlls/wined3d/state.c | 16 +++++++++++-----
2 files changed, 15 insertions(+), 5 deletions(-)
diff --git a/dlls/wined3d/device.c b/dlls/wined3d/device.c
index 654bf13..3ec9f40 100644
--- a/dlls/wined3d/device.c
+++ b/dlls/wined3d/device.c
@@ -5134,6 +5134,10 @@ static HRESULT WINAPI IWineD3DDeviceImpl_SetRenderTarget(IWineD3DDevice *iface,
viewport.MaxZ = 1.0f;
viewport.MinZ = 0.0f;
IWineD3DDeviceImpl_SetViewport(iface, &viewport);
+ /* Make sure the viewport state is dirty, because the render_offscreen thing affects it.
+ * SetViewport may catch NOP viewport changes, which would occur when switching between equally sized targets
+ */
+ IWineD3DDeviceImpl_MarkStateDirty(This, STATE_VIEWPORT);
/* Activate the new render target for now. This shouldn't stay here, but is needed until all methods using gl activate the
* ctx properly.
diff --git a/dlls/wined3d/state.c b/dlls/wined3d/state.c
index 00f4876..cf1b7f4 100644
--- a/dlls/wined3d/state.c
+++ b/dlls/wined3d/state.c
@@ -3015,11 +3015,17 @@ static void vertexdeclaration(DWORD state, IWineD3DStateBlockImpl *stateblock, W
static void viewport(DWORD state, IWineD3DStateBlockImpl *stateblock, WineD3DContext *context) {
glDepthRange(stateblock->viewport.MinZ, stateblock->viewport.MaxZ);
checkGLcall("glDepthRange");
- /* Note: GL requires lower left, DirectX supplies upper left */
- /* TODO: replace usage of renderTarget with context management */
- glViewport(stateblock->viewport.X,
- (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
- stateblock->viewport.Width, stateblock->viewport.Height);
+ /* Note: GL requires lower left, DirectX supplies upper left. This is reversed when using offscreen rendering
+ */
+ if(stateblock->wineD3DDevice->render_offscreen) {
+ glViewport(stateblock->viewport.X,
+ stateblock->viewport.Y,
+ stateblock->viewport.Width, stateblock->viewport.Height);
+ } else {
+ glViewport(stateblock->viewport.X,
+ (((IWineD3DSurfaceImpl *)stateblock->wineD3DDevice->render_targets[0])->currentDesc.Height - (stateblock->viewport.Y + stateblock->viewport.Height)),
+ stateblock->viewport.Width, stateblock->viewport.Height);
+ }
checkGLcall("glViewport");
Module: wine
Branch: master
Commit: daeffc897bc22253312d8b62634e3a6fa83e6cfc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=daeffc897bc22253312d8b626…
Author: Stefan Dösinger <stefan(a)codeweavers.com>
Date: Sun Mar 4 23:47:57 2007 +0100
wined3d: Use an aux buffer as blitting helper if available.
This helps performance a bit because the function does not have to
wait for the 2nd read to finish before returning. Only do that if we
have an aux buffer to mess with for free though.
---
dlls/wined3d/surface.c | 48 ++++++++++++++++++++++++++++++++++--------------
1 files changed, 34 insertions(+), 14 deletions(-)
diff --git a/dlls/wined3d/surface.c b/dlls/wined3d/surface.c
index 2a1cc60..c4eefc9 100644
--- a/dlls/wined3d/surface.c
+++ b/dlls/wined3d/surface.c
@@ -2261,12 +2261,24 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
float left, right, top, bottom; /* Texture coordinates */
UINT fbwidth = Src->currentDesc.Width;
UINT fbheight = Src->currentDesc.Height;
+ GLenum drawBuffer = GL_BACK;
TRACE("Using hwstretch blit\n");
/* Activate the Proper context for reading from the source surface, set it up for blitting */
ENTER_GL();
ActivateContext(myDevice, SrcSurface, CTXUSAGE_BLIT);
+ /* Try to use an aux buffer for drawing the rectangle. This way it doesn't need restoring.
+ * This way we don't have to wait for the 2nd readback to finish to leave this function.
+ */
+ if(GL_LIMITS(aux_buffers) >= 2) {
+ /* Got more than one aux buffer? Use the 2nd aux buffer */
+ drawBuffer = GL_AUX1;
+ } else if((swapchain || myDevice->offscreenBuffer == GL_BACK) && GL_LIMITS(aux_buffers) >= 1) {
+ /* Only one aux buffer, but it isn't used (Onscreen rendering, or non-aux orm)? Use it! */
+ drawBuffer = GL_AUX0;
+ }
+
if(!swapchain && wined3d_settings.offscreen_rendering_mode == ORM_FBO) {
glGenTextures(1, &backup);
checkGLcall("glGenTextures\n");
@@ -2350,6 +2362,9 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
+ glDrawBuffer(drawBuffer);
+ glReadBuffer(drawBuffer);
+
glBegin(GL_QUADS);
/* bottom left */
glTexCoord2f(left, bottom);
@@ -2383,23 +2398,28 @@ static inline void fb_copy_to_texture_hwstretch(IWineD3DSurfaceImpl *This, IWine
glBindTexture(GL_TEXTURE_2D, backup ? backup : Src->glDescription.textureName);
checkGLcall("glBindTexture(GL_TEXTURE_2D, Src->glDescription.textureName)");
- glBegin(GL_QUADS);
- /* top left */
- glTexCoord2f(0.0, (float) fbheight / (float) Src->pow2Height);
- glVertex2i(0, 0);
+ if(drawBuffer == GL_BACK) {
+ glBegin(GL_QUADS);
+ /* top left */
+ glTexCoord2f(0.0, (float) fbheight / (float) Src->pow2Height);
+ glVertex2i(0, 0);
- /* bottom left */
- glTexCoord2f(0.0, 0.0);
- glVertex2i(0, fbheight);
+ /* bottom left */
+ glTexCoord2f(0.0, 0.0);
+ glVertex2i(0, fbheight);
- /* bottom right */
- glTexCoord2f((float) fbwidth / (float) Src->pow2Width, 0.0);
- glVertex2i(fbwidth, Src->currentDesc.Height);
+ /* bottom right */
+ glTexCoord2f((float) fbwidth / (float) Src->pow2Width, 0.0);
+ glVertex2i(fbwidth, Src->currentDesc.Height);
- /* top right */
- glTexCoord2f((float) fbwidth / (float) Src->pow2Width, (float) fbheight / (float) Src->pow2Height);
- glVertex2i(fbwidth, 0);
- glEnd();
+ /* top right */
+ glTexCoord2f((float) fbwidth / (float) Src->pow2Width, (float) fbheight / (float) Src->pow2Height);
+ glVertex2i(fbwidth, 0);
+ glEnd();
+ } else {
+ /* Restore the old draw buffer */
+ glDrawBuffer(GL_BACK);
+ }
/* Cleanup */
if(src != Src->glDescription.textureName && src != backup) {