GPU: Use postshader for direct VRAM draws again.

Also centralize the pixel texture code while at it.
This commit is contained in:
Unknown W. Brackets committed 2020-05-13 18:10:09 -07:00
1 parent 762b656ea2
commit 2faab0e082
13 files changed
+82 -212

No files matched your search

+1 -48
View File
@@ -117,6 +117,7 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
ShaderTranslationInit();
presentation_->SetLanguage(HLSL_DX9);
preferredPixelsFormat_ = Draw::DataFormat::B8G8R8A8_UNORM;
}
FramebufferManagerDX9::~FramebufferManagerDX9() {
@@ -159,54 +160,6 @@ static const D3DVERTEXELEMENT9 g_FramebufferVertexElements[] = {
drawEngine_ = td;
}
Draw::Texture *FramebufferManagerDX9::MakePixelTexture(const u8 *srcPixels, GEBufferFormat srcPixelFormat, int srcStride, int width, int height, float &u1, float &v1) {
auto generateTexture = [&](uint8_t *data, const uint8_t *initData, uint32_t w, uint32_t h, uint32_t d, uint32_t byteStride, uint32_t sliceByteStride) {
for (int y = 0; y < height; y++) {
const u16_le *src16 = (const u16_le *)srcPixels + srcStride * y;
const u32_le *src32 = (const u32_le *)srcPixels + srcStride * y;
u32 *dst = (u32 *)(data + byteStride * y);
switch (srcPixelFormat) {
case GE_FORMAT_565:
ConvertRGB565ToBGRA8888(dst, src16, width);
break;
case GE_FORMAT_5551:
ConvertRGBA5551ToBGRA8888(dst, src16, width);
break;
case GE_FORMAT_4444:
ConvertRGBA4444ToBGRA8888(dst, src16, width);
break;
case GE_FORMAT_8888:
ConvertRGBA8888ToBGRA8888(dst, src32, width);
break;
case GE_FORMAT_INVALID:
_dbg_assert_msg_(G3D, false, "Invalid pixelFormat passed to DrawPixels().");
break;
}
}
};
Draw::TextureDesc desc{
Draw::TextureType::LINEAR2D,
Draw::DataFormat::B8G8R8A8_UNORM,
width,
height,
1,
1,
false,
"DrawPixels",
{ (uint8_t *)srcPixels },
generateTexture,
};
Draw::Texture *tex = draw_->CreateTexture(desc);
if (!tex)
ERROR_LOG(G3D, "Failed to create drawpixels texture");
return tex;
}
void FramebufferManagerDX9::DrawActiveTexture(float x, float y, float w, float h, float destW, float destH, float u0, float v0, float u1, float v1, int uvRotation, int flags) {
// TODO: StretchRect instead when possible?
float coord[20] = {