Skip to content

Commit

Permalink
Merge pull request #8130 from hrydgard/flip-framebuffers
Browse files Browse the repository at this point in the history
Use a flipped coordinate system in framebuffers to avoid manual flipping of texture coordinates
  • Loading branch information
hrydgard committed Nov 2, 2015
2 parents f3b1fca + a1ad278 commit 728d9e5
Show file tree
Hide file tree
Showing 23 changed files with 221 additions and 254 deletions.
5 changes: 3 additions & 2 deletions GPU/Common/FramebufferCommon.cpp
Expand Up @@ -119,7 +119,8 @@ FramebufferManagerCommon::FramebufferManagerCommon() :
frameLastFramebufUsed_(0),
currentRenderVfb_(0),
framebufRangeEnd_(0),
hackForce04154000Download_(false) {
hackForce04154000Download_(false),
updateVRAM_(false) {
UpdateSize();
}

Expand Down Expand Up @@ -795,7 +796,7 @@ void FramebufferManagerCommon::NotifyBlockTransferAfter(u32 dstBasePtr, int dstS
(displayBuffer != 0 && dstBasePtr == displayBuffer)) &&
dstStride == 512 && height == 272 && !useBufferedRendering_) {
FlushBeforeCopy();
DrawFramebuffer(Memory::GetPointerUnchecked(dstBasePtr), displayFormat_, 512, false);
DrawFramebufferToOutput(Memory::GetPointerUnchecked(dstBasePtr), displayFormat_, 512, false);
}

if (MayIntersectFramebuffer(srcBasePtr) || MayIntersectFramebuffer(dstBasePtr)) {
Expand Down
4 changes: 2 additions & 2 deletions GPU/Common/FramebufferCommon.h
Expand Up @@ -162,7 +162,7 @@ class FramebufferManagerCommon {
virtual void ReadFramebufferToMemory(VirtualFramebuffer *vfb, bool sync, int x, int y, int w, int h) = 0;
virtual void MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
virtual void DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) = 0;
virtual void DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) = 0;
virtual void DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) = 0;

size_t NumVFBs() const { return vfbs_.size(); }

Expand Down Expand Up @@ -220,7 +220,7 @@ class FramebufferManagerCommon {
virtual void DecimateFBOs() = 0;

// Used by ReadFramebufferToMemory and later framebuffer block copies
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip = false) = 0;
virtual void BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) = 0;

void EstimateDrawingSize(u32 fb_address, GEBufferFormat fb_format, int viewport_width, int viewport_height, int region_width, int region_height, int scissor_width, int scissor_height, int fb_stride, int &drawing_width, int &drawing_height);
u32 FramebufferByteSize(const VirtualFramebuffer *vfb) const;
Expand Down
4 changes: 0 additions & 4 deletions GPU/Common/ShaderId.cpp
Expand Up @@ -23,7 +23,6 @@ std::string VertexShaderDesc(const ShaderID &id) {
if (id.Bit(VS_BIT_NORM_REVERSE)) desc << "RevN ";
if (id.Bit(VS_BIT_DO_TEXTURE)) desc << "Tex ";
if (id.Bit(VS_BIT_DO_TEXTURE_PROJ)) desc << "TexProj ";
if (id.Bit(VS_BIT_FLIP_TEXTURE)) desc << "Flip ";
int uvgMode = id.Bits(VS_BIT_UVGEN_MODE, 2);
const char *uvgModes[4] = { "UV ", "UVMtx ", "UVEnv ", "UVUnk " };
int ls0 = id.Bits(VS_BIT_LS0, 2);
Expand Down Expand Up @@ -72,7 +71,6 @@ void ComputeVertexShaderID(ShaderID *id_out, u32 vertType, bool useHWTransform)

if (doTexture) {
id.SetBit(VS_BIT_DO_TEXTURE);
id.SetBit(VS_BIT_FLIP_TEXTURE, gstate_c.flipTexture);
id.SetBit(VS_BIT_DO_TEXTURE_PROJ, doTextureProjection);
}

Expand Down Expand Up @@ -138,7 +136,6 @@ std::string FragmentShaderDesc(const ShaderID &id) {
if (id.Bit(FS_BIT_CLEARMODE)) desc << "Clear ";
if (id.Bit(FS_BIT_DO_TEXTURE)) desc << "Tex ";
if (id.Bit(FS_BIT_DO_TEXTURE_PROJ)) desc << "TexProj ";
if (id.Bit(FS_BIT_FLIP_TEXTURE)) desc << "Flip ";
if (id.Bit(FS_BIT_TEXALPHA)) desc << "TexAlpha ";
if (id.Bit(FS_BIT_TEXTURE_AT_OFFSET)) desc << "TexOffs ";
if (id.Bit(FS_BIT_LMODE)) desc << "LM ";
Expand Down Expand Up @@ -223,7 +220,6 @@ void ComputeFragmentShaderID(ShaderID *id_out, uint32_t vertType) {
id.SetBit(FS_BIT_DO_TEXTURE);
id.SetBits(FS_BIT_TEXFUNC, 3, gstate.getTextureFunction());
id.SetBit(FS_BIT_TEXALPHA, doTextureAlpha & 1); // rgb or rgba
id.SetBit(FS_BIT_FLIP_TEXTURE, gstate_c.flipTexture);
if (gstate_c.needShaderTexClamp) {
bool textureAtOffset = gstate_c.curTextureXOffset != 0 || gstate_c.curTextureYOffset != 0;
// 4 bits total.
Expand Down
2 changes: 0 additions & 2 deletions GPU/Common/ShaderId.h
Expand Up @@ -11,7 +11,6 @@ enum {
VS_BIT_ENABLE_FOG = 2,
VS_BIT_HAS_COLOR = 3,
VS_BIT_DO_TEXTURE = 4,
VS_BIT_FLIP_TEXTURE = 5,
VS_BIT_DO_TEXTURE_PROJ = 6,
VS_BIT_USE_HW_TRANSFORM = 8,
VS_BIT_HAS_NORMAL = 9, // conditioned on hw transform
Expand Down Expand Up @@ -49,7 +48,6 @@ enum {
FS_BIT_DO_TEXTURE = 1,
FS_BIT_TEXFUNC = 2, // 3 bits
FS_BIT_TEXALPHA = 5,
FS_BIT_FLIP_TEXTURE = 6,
FS_BIT_SHADER_TEX_CLAMP = 7,
FS_BIT_CLAMP_S = 8,
FS_BIT_CLAMP_T = 9,
Expand Down
51 changes: 18 additions & 33 deletions GPU/Common/SoftwareTransformCommon.cpp
Expand Up @@ -176,8 +176,6 @@ void SoftwareTransform(
}

VertexReader reader(decoded, decVtxFormat, vertType);
// We flip in the fragment shader for GE_TEXMAP_TEXTURE_MATRIX.
const bool flipV = gstate_c.flipTexture && gstate.getUVGenMode() != GE_TEXMAP_TEXTURE_MATRIX;
if (throughmode) {
for (int index = 0; index < maxIndex; index++) {
// Do not touch the coordinates or the colors. No lighting.
Expand All @@ -201,11 +199,6 @@ void SoftwareTransform(
vert.u = 0.0f;
vert.v = 0.0f;
}
// Scale UV?

if (flipV) {
vert.v = 1.0f - vert.v;
}

// Ignore color1 and fog, never used in throughmode anyway.
// The w of uv is also never used (hardcoded to 1.0.)
Expand Down Expand Up @@ -397,9 +390,6 @@ void SoftwareTransform(
memcpy(&transformed[index].x, v, 3 * sizeof(float));
transformed[index].fog = fogCoef;
memcpy(&transformed[index].u, uv, 3 * sizeof(float));
if (flipV) {
transformed[index].v = 1.0f - transformed[index].v;
}
transformed[index].color0_32 = c0.ToRGBA();
transformed[index].color1_32 = c1.ToRGBA();

Expand Down Expand Up @@ -431,21 +421,14 @@ void SoftwareTransform(
bool tlOutside;
bool tlAlmostOutside;
bool brOutside;
if (gstate_c.flipTexture) {
// This is flipped for OpenGL, but the same logic as unflipped, so look there.
tlOutside = transformed[0].v < -invTexH && transformed[0].v >= 1.0f - heightFactor;
brOutside = transformed[1].v < -invTexH && transformed[1].v >= 1.0f - heightFactor;
tlAlmostOutside = transformed[0].v <= 0.5f && transformed[0].v >= 1.0f - heightFactor;
} else {
// If we're outside heightFactor, then v must be wrapping or clamping. Avoid this workaround.
// If we're <= 1.0f, we're inside the framebuffer (workaround not needed.)
// We buffer that 1.0f a little more with a texel to avoid some false positives.
tlOutside = transformed[0].v <= heightFactor && transformed[0].v > 1.0f + invTexH;
brOutside = transformed[1].v <= heightFactor && transformed[1].v > 1.0f + invTexH;
// Careful: if br is outside, but tl is well inside, this workaround still doesn't make sense.
// We go with halfway, since we overestimate framebuffer heights sometimes but not by much.
tlAlmostOutside = transformed[0].v <= heightFactor && transformed[0].v >= 0.5f;
}
// If we're outside heightFactor, then v must be wrapping or clamping. Avoid this workaround.
// If we're <= 1.0f, we're inside the framebuffer (workaround not needed.)
// We buffer that 1.0f a little more with a texel to avoid some false positives.
tlOutside = transformed[0].v <= heightFactor && transformed[0].v > 1.0f + invTexH;
brOutside = transformed[1].v <= heightFactor && transformed[1].v > 1.0f + invTexH;
// Careful: if br is outside, but tl is well inside, this workaround still doesn't make sense.
// We go with halfway, since we overestimate framebuffer heights sometimes but not by much.
tlAlmostOutside = transformed[0].v <= heightFactor && transformed[0].v >= 0.5f;
if (tlOutside || (brOutside && tlAlmostOutside)) {
// Okay, so we're texturing from outside the framebuffer, but inside the texture height.
// Breath of Fire 3 does this to access a render surface at an offset.
Expand All @@ -464,13 +447,7 @@ void SoftwareTransform(
for (int index = 0; index < maxIndex; ++index) {
transformed[index].u *= widthFactor / oldWidthFactor;
// Inverse it back to scale to the new FBO, and add 1.0f to account for old FBO.
if (gstate_c.flipTexture) {
transformed[index].v = (1.0f - transformed[index].v) / oldHeightFactor;
transformed[index].v -= yDiff;
transformed[index].v = 1.0f - (transformed[index].v * heightFactor);
} else {
transformed[index].v = (transformed[index].v / oldHeightFactor - yDiff) * heightFactor;
}
transformed[index].v = (transformed[index].v / oldHeightFactor - yDiff) * heightFactor;
}
}
}
Expand All @@ -486,18 +463,26 @@ void SoftwareTransform(
numTrans = vertexCount;
drawIndexed = true;
} else {
bool useBufferedRendering = g_Config.iRenderingMode != FB_NON_BUFFERED_MODE;
if (useBufferedRendering)
ySign = -ySign;

float flippedMatrix[16];
if (!throughmode) {
memcpy(&flippedMatrix, gstate.projMatrix, 16 * sizeof(float));

const bool invertedY = gstate_c.vpHeight < 0;
const bool invertedY = useBufferedRendering ? (gstate_c.vpHeight > 0) : (gstate_c.vpHeight < 0);
if (invertedY) {
flippedMatrix[1] = -flippedMatrix[1];
flippedMatrix[5] = -flippedMatrix[5];
flippedMatrix[9] = -flippedMatrix[9];
flippedMatrix[13] = -flippedMatrix[13];
}
const bool invertedX = gstate_c.vpWidth < 0;
if (invertedX) {
flippedMatrix[0] = -flippedMatrix[0];
flippedMatrix[4] = -flippedMatrix[4];
flippedMatrix[8] = -flippedMatrix[8];
flippedMatrix[12] = -flippedMatrix[12];
}
}
Expand Down
105 changes: 42 additions & 63 deletions GPU/Directx9/FramebufferDX9.cpp
Expand Up @@ -183,21 +183,21 @@ namespace DX9 {
}

void FramebufferManagerDX9::DrawPixels(VirtualFramebuffer *vfb, int dstX, int dstY, const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height) {
if (useBufferedRendering_ && vfb->fbo) {
if (useBufferedRendering_ && vfb && vfb->fbo) {
fbo_bind_as_render_target(vfb->fbo);
dxstate.viewport.set(0, 0, vfb->renderWidth, vfb->renderHeight);
} else {
float x, y, w, h;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, false, false);
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)pixelWidth_, (float)pixelHeight_, ROTATION_LOCKED_HORIZONTAL, false);
dxstate.viewport.set(x, y, w, h);
}
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, width, height);
DisableState();
DrawActiveTexture(drawPixelsTex_, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, false, 0.0f, 0.0f, 1.0f, 1.0f);
DrawActiveTexture(drawPixelsTex_, dstX, dstY, width, height, vfb->bufferWidth, vfb->bufferHeight, 0.0f, 0.0f, 1.0f, 1.0f, ROTATION_LOCKED_HORIZONTAL);
textureCache_->ForgetLastTexture();
}

void FramebufferManagerDX9::DrawFramebuffer(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) {
void FramebufferManagerDX9::DrawFramebufferToOutput(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, bool applyPostShader) {
MakePixelTexture(srcPixels, srcPixelFormat, srcStride, 512, 272);

DisableState();
Expand All @@ -208,14 +208,10 @@ namespace DX9 {
float x, y, w, h;
int uvRotation = (g_Config.iRenderingMode != FB_NON_BUFFERED_MODE) ? g_Config.iInternalScreenRotation : ROTATION_LOCKED_HORIZONTAL;
CenterDisplayOutputRect(&x, &y, &w, &h, 480.0f, 272.0f, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, uvRotation, false);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, 0.0f, 0.0f, 480.0f / 512.0f, uvRotation);
DrawActiveTexture(drawPixelsTex_, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, 0.0f, 0.0f, 480.0f / 512.0f, 1.0f, uvRotation);
}

void FramebufferManagerDX9::DrawActiveTexture(LPDIRECT3DTEXTURE9 tex, float x, float y, float w, float h, float destW, float destH, bool flip, float u0, float v0, float u1, float v1, int uvRotation) {
if (flip) {
std::swap(v0, v1);
}

void FramebufferManagerDX9::DrawActiveTexture(LPDIRECT3DTEXTURE9 tex, float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation) {
// TODO: StretchRect instead?
float coord[20] = {
x,y,0, u0,v0,
Expand Down Expand Up @@ -658,7 +654,7 @@ namespace DX9 {
}
}

BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0, false);
BlitFramebuffer(&copyInfo, x, y, framebuffer, x, y, w, h, 0);

RebindFramebuffer();
pD3Ddevice->SetTexture(stage, fbo_get_color_texture(renderCopy));
Expand Down Expand Up @@ -732,7 +728,7 @@ namespace DX9 {

if (!vfb) {
// Just a pointer to plain memory to draw. Draw it.
DrawFramebuffer(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_, true);
DrawFramebufferToOutput(Memory::GetPointer(displayFramebufPtr_), displayFormat_, displayStride_, true);
return;
}
} else {
Expand Down Expand Up @@ -794,7 +790,7 @@ namespace DX9 {
}
dxstate.texMipFilter.set(D3DTEXF_NONE);
dxstate.texMipLodBias.set(0);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, false, u0, v0, u1, v1, uvRotation);
DrawActiveTexture(colorTexture, x, y, w, h, (float)PSP_CoreParameter().pixelWidth, (float)PSP_CoreParameter().pixelHeight, u0, v0, u1, v1, uvRotation);
}
}
/*
Expand Down Expand Up @@ -837,7 +833,7 @@ namespace DX9 {
#endif

if (vfb) {
// We'll pseudo-blit framebuffers here to get a resized and flipped version of vfb.
// We'll pseudo-blit framebuffers here to get a resized version of vfb.
// For now we'll keep these on the same struct as the ones that can get displayed
// (and blatantly copy work already done above while at it).
VirtualFramebuffer *nvfb = 0;
Expand Down Expand Up @@ -935,22 +931,22 @@ namespace DX9 {
gameUsesSequentialCopies_ = true;
}
}
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0, false);
BlitFramebuffer(nvfb, x, y, vfb, x, y, w, h, 0);

PackFramebufferDirectx9_(nvfb, x, y, w, h);
RebindFramebuffer();
}
}

void FramebufferManagerDX9::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp, bool flip) {
void FramebufferManagerDX9::BlitFramebuffer(VirtualFramebuffer *dst, int dstX, int dstY, VirtualFramebuffer *src, int srcX, int srcY, int w, int h, int bpp) {
if (!dst->fbo || !src->fbo || !useBufferedRendering_) {
// This can happen if they recently switched from non-buffered.
fbo_unbind();
return;
}

float srcXFactor = flip ? 1.0f : (float)src->renderWidth / (float)src->bufferWidth;
float srcYFactor = flip ? 1.0f : (float)src->renderHeight / (float)src->bufferHeight;
float srcXFactor = (float)src->renderWidth / (float)src->bufferWidth;
float srcYFactor = (float)src->renderHeight / (float)src->bufferHeight;
const int srcBpp = src->format == GE_FORMAT_8888 ? 4 : 2;
if (srcBpp != bpp && bpp != 0) {
srcXFactor = (srcXFactor * bpp) / srcBpp;
Expand All @@ -960,8 +956,8 @@ namespace DX9 {
int srcY1 = srcY * srcYFactor;
int srcY2 = (srcY + h) * srcYFactor;

float dstXFactor = flip ? 1.0f : (float)dst->renderWidth / (float)dst->bufferWidth;
float dstYFactor = flip ? 1.0f : (float)dst->renderHeight / (float)dst->bufferHeight;
float dstXFactor = (float)dst->renderWidth / (float)dst->bufferWidth;
float dstYFactor = (float)dst->renderHeight / (float)dst->bufferHeight;
const int dstBpp = dst->format == GE_FORMAT_8888 ? 4 : 2;
if (dstBpp != bpp && bpp != 0) {
dstXFactor = (dstXFactor * bpp) / dstBpp;
Expand All @@ -971,50 +967,33 @@ namespace DX9 {
int dstY1 = dstY * dstYFactor;
int dstY2 = (dstY + h) * dstYFactor;

if (flip) {
fbo_bind_as_render_target(dst->fbo);
dxstate.viewport.set(0, 0, dst->renderWidth, dst->renderHeight);
DisableState();

fbo_bind_color_as_texture(src->fbo, 0);

float srcW = src->bufferWidth;
float srcH = src->bufferHeight;
DrawActiveTexture(0, dstX1, dstY, w * dstXFactor, h, dst->bufferWidth, dst->bufferHeight, flip, srcX1 / srcW, srcY / srcH, srcX2 / srcW, (srcY + h) / srcH);
pD3Ddevice->SetTexture(0, NULL);
textureCache_->ForgetLastTexture();
dxstate.viewport.restore();

RebindFramebuffer();
} else {
LPDIRECT3DSURFACE9 srcSurf = fbo_get_color_for_read(src->fbo);
LPDIRECT3DSURFACE9 dstSurf = fbo_get_color_for_write(dst->fbo);
RECT srcRect = {srcX1, srcY1, srcX2, srcY2};
RECT dstRect = {dstX1, dstY1, dstX2, dstY2};

D3DSURFACE_DESC desc;
srcSurf->GetDesc(&desc);
srcRect.right = std::min(srcRect.right, (LONG)desc.Width);
srcRect.bottom = std::min(srcRect.bottom, (LONG)desc.Height);
LPDIRECT3DSURFACE9 srcSurf = fbo_get_color_for_read(src->fbo);
LPDIRECT3DSURFACE9 dstSurf = fbo_get_color_for_write(dst->fbo);
RECT srcRect = {srcX1, srcY1, srcX2, srcY2};
RECT dstRect = {dstX1, dstY1, dstX2, dstY2};

dstSurf->GetDesc(&desc);
dstRect.right = std::min(dstRect.right, (LONG)desc.Width);
dstRect.bottom = std::min(dstRect.bottom, (LONG)desc.Height);

// Direct3D 9 doesn't support rect -> self.
FBO *srcFBO = src->fbo;
if (src == dst) {
FBO *tempFBO = GetTempFBO(src->renderWidth, src->renderHeight, (FBOColorDepth)src->colorDepth);
HRESULT hr = fbo_blit_color(src->fbo, &srcRect, tempFBO, &srcRect, D3DTEXF_POINT);
if (SUCCEEDED(hr)) {
srcFBO = tempFBO;
}
D3DSURFACE_DESC desc;
srcSurf->GetDesc(&desc);
srcRect.right = std::min(srcRect.right, (LONG)desc.Width);
srcRect.bottom = std::min(srcRect.bottom, (LONG)desc.Height);

dstSurf->GetDesc(&desc);
dstRect.right = std::min(dstRect.right, (LONG)desc.Width);
dstRect.bottom = std::min(dstRect.bottom, (LONG)desc.Height);

// Direct3D 9 doesn't support rect -> self.
FBO *srcFBO = src->fbo;
if (src == dst) {
FBO *tempFBO = GetTempFBO(src->renderWidth, src->renderHeight, (FBOColorDepth)src->colorDepth);
HRESULT hr = fbo_blit_color(src->fbo, &srcRect, tempFBO, &srcRect, D3DTEXF_POINT);
if (SUCCEEDED(hr)) {
srcFBO = tempFBO;
}
}

HRESULT hr = fbo_blit_color(srcFBO, &srcRect, dst->fbo, &dstRect, D3DTEXF_POINT);
if (FAILED(hr)) {
ERROR_LOG_REPORT(G3D, "fbo_blit_color failed in blit: %08x (%08x -> %08x)", hr, src->fb_address, dst->fb_address);
}
HRESULT hr = fbo_blit_color(srcFBO, &srcRect, dst->fbo, &dstRect, D3DTEXF_POINT);
if (FAILED(hr)) {
ERROR_LOG_REPORT(G3D, "fbo_blit_color failed in blit: %08x (%08x -> %08x)", hr, src->fb_address, dst->fb_address);
}
}

Expand Down Expand Up @@ -1377,7 +1356,7 @@ namespace DX9 {
GPUDebugBufferFormat fmt = GPU_DBG_FORMAT_24BIT_8X;
int pixelSize = 4;

buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, gstate_c.flipTexture);
buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, false);
memcpy(buffer.GetData(), locked.pBits, locked.Pitch * desc.Height);
success = true;
tex->UnlockRect(0);
Expand Down Expand Up @@ -1418,7 +1397,7 @@ namespace DX9 {
GPUDebugBufferFormat fmt = GPU_DBG_FORMAT_24X_8BIT;
int pixelSize = 4;

buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, gstate_c.flipTexture);
buffer.Allocate(locked.Pitch / pixelSize, desc.Height, fmt, false);
memcpy(buffer.GetData(), locked.pBits, locked.Pitch * desc.Height);
success = true;
tex->UnlockRect(0);
Expand Down

0 comments on commit 728d9e5

Please sign in to comment.