D3D11: Fix reverse colors in drawpixels, fix a potential crash

This commit is contained in:
Henrik Rydgård 2017-02-12 12:07:37 +01:00
parent 4fbb537c92
commit 07c88ef2b0
2 changed files with 4 additions and 5 deletions

View file

@ -206,7 +206,6 @@ void FramebufferManagerD3D11::MakePixelTexture(const u8 *srcPixels, GEBufferForm
convBuf = (u8*)map.pData;
// Final format is BGRA(directx)
if (srcPixelFormat != GE_FORMAT_8888 || srcStride != 512) {
for (int y = 0; y < height; y++) {
switch (srcPixelFormat) {
@ -237,7 +236,7 @@ void FramebufferManagerD3D11::MakePixelTexture(const u8 *srcPixels, GEBufferForm
{
const u32_le *src = (const u32_le *)srcPixels + srcStride * y;
u32 *dst = (u32 *)(convBuf + map.RowPitch * y);
ConvertRGBA8888ToBGRA8888(dst, src, width);
memcpy(dst, src, width * 4);
}
break;
}
@ -246,7 +245,7 @@ void FramebufferManagerD3D11::MakePixelTexture(const u8 *srcPixels, GEBufferForm
for (int y = 0; y < height; y++) {
const u32_le *src = (const u32_le *)srcPixels + srcStride * y;
u32 *dst = (u32 *)(convBuf + map.RowPitch * y);
ConvertRGBA8888ToBGRA8888(dst, src, width);
memcpy(dst, src, width * 4);
}
}

View file

@ -1102,12 +1102,12 @@ void D3D11DrawContext::BindSamplerStates(int start, int count, SamplerState **st
}
void D3D11DrawContext::Clear(int mask, uint32_t colorval, float depthVal, int stencilVal) {
if (mask & ClearFlag::COLOR) {
if ((mask & ClearFlag::COLOR) && curRenderTargetView_) {
float colorRGBA[4];
Uint8x4ToFloat4(colorRGBA, colorval);
context_->ClearRenderTargetView(curRenderTargetView_, colorRGBA);
}
if (mask & (ClearFlag::DEPTH | ClearFlag::STENCIL)) {
if ((mask & (ClearFlag::DEPTH | ClearFlag::STENCIL)) && curDepthStencilView_) {
UINT clearFlag = 0;
if (mask & ClearFlag::DEPTH)
clearFlag |= D3D11_CLEAR_DEPTH;