- change software renderer upload code to use GL_STREAM_DRAW and a memcpy from system memory

This commit is contained in:
Magnus Norddahl 2018-07-18 06:46:30 +02:00
parent 4e2385e912
commit e93d1e3ebc
3 changed files with 10 additions and 3 deletions

View file

@ -296,7 +296,7 @@ void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
{
glGenBuffers(1, &glBufferID);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_DYNAMIC_DRAW);
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_STREAM_DRAW);
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
}
}

View file

@ -111,11 +111,17 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
mat->AddTextureLayer(PaletteTexture.get());
FBBuffer.Resize(screen->GetWidth() * screen->GetHeight());
}
auto buf = fbtex->SystemTexture[0]->MapBuffer();
if (!buf) I_FatalError("Unable to map buffer for software rendering");
auto buf = (uint8_t*)&FBBuffer[0];
buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf);
SWRenderer->RenderView(player, &buffer);
auto pbobuf = fbtex->SystemTexture[0]->MapBuffer();
if (!pbobuf) I_FatalError("Unable to map buffer for software rendering");
memcpy(pbobuf, buf, FBBuffer.Size() * (V_IsTrueColor() ? 4 : 1));
fbtex->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();

View file

@ -14,6 +14,7 @@ class SWSceneDrawer
{
std::unique_ptr<FTexture> PaletteTexture;
std::unique_ptr<FSWSceneTexture> FBTexture[2];
TArray<uint32_t> FBBuffer;
int FBTextureIndex = 0;
bool FBIsTruecolor = false;