mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-14 08:30:50 +00:00
- change software renderer back to writing directly into the pixel buffer object, but change the creation and mapping so that hopefully all vendors put it in system memory
This commit is contained in:
parent
23c0f8f6ac
commit
a0a7fd53e8
3 changed files with 16 additions and 10 deletions
|
@ -296,6 +296,9 @@ void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
|
||||||
{
|
{
|
||||||
glGenBuffers(1, &glBufferID);
|
glGenBuffers(1, &glBufferID);
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
|
||||||
|
if (screen->hwcaps & RFL_BUFFER_STORAGE)
|
||||||
|
glBufferStorage(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT | GL_CLIENT_STORAGE_BIT);
|
||||||
|
else
|
||||||
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_STREAM_DRAW);
|
glBufferData(GL_PIXEL_UNPACK_BUFFER, w*h*texelsize, nullptr, GL_STREAM_DRAW);
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0);
|
||||||
}
|
}
|
||||||
|
@ -305,7 +308,16 @@ void FHardwareTexture::AllocateBuffer(int w, int h, int texelsize)
|
||||||
uint8_t *FHardwareTexture::MapBuffer()
|
uint8_t *FHardwareTexture::MapBuffer()
|
||||||
{
|
{
|
||||||
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
|
glBindBuffer(GL_PIXEL_UNPACK_BUFFER, glBufferID);
|
||||||
return (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_WRITE_ONLY);
|
if (screen->hwcaps & RFL_BUFFER_STORAGE)
|
||||||
|
{
|
||||||
|
GLint size = -1;
|
||||||
|
glGetBufferParameteriv(GL_PIXEL_UNPACK_BUFFER, GL_BUFFER_SIZE, &size);
|
||||||
|
return (uint8_t*)glMapBufferRange(GL_PIXEL_UNPACK_BUFFER, 0, size, GL_MAP_READ_BIT | GL_MAP_WRITE_BIT);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return (uint8_t*)glMapBuffer(GL_PIXEL_UNPACK_BUFFER, GL_READ_WRITE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
|
@ -111,17 +111,12 @@ sector_t *SWSceneDrawer::RenderView(player_t *player)
|
||||||
fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
fbtex->SystemTexture[0]->AllocateBuffer(screen->GetWidth(), screen->GetHeight(), V_IsTrueColor() ? 4 : 1);
|
||||||
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
auto mat = FMaterial::ValidateTexture(fbtex.get(), false);
|
||||||
mat->AddTextureLayer(PaletteTexture.get());
|
mat->AddTextureLayer(PaletteTexture.get());
|
||||||
|
|
||||||
FBBuffer.Resize(screen->GetWidth() * screen->GetHeight());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
auto buf = (uint8_t*)&FBBuffer[0];
|
auto buf = fbtex->SystemTexture[0]->MapBuffer();
|
||||||
|
if (!buf) I_FatalError("Unable to map buffer for software rendering");
|
||||||
buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf);
|
buffer.SetBuffer(screen->GetWidth(), screen->GetHeight(), screen->GetWidth(), buf);
|
||||||
SWRenderer->RenderView(player, &buffer);
|
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");
|
fbtex->SystemTexture[0]->CreateTexture(nullptr, screen->GetWidth(), screen->GetHeight(), 0, false, 0, "swbuffer");
|
||||||
|
|
||||||
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
auto map = swrenderer::CameraLight::Instance()->ShaderColormap();
|
||||||
|
|
|
@ -14,7 +14,6 @@ class SWSceneDrawer
|
||||||
{
|
{
|
||||||
std::unique_ptr<FTexture> PaletteTexture;
|
std::unique_ptr<FTexture> PaletteTexture;
|
||||||
std::unique_ptr<FSWSceneTexture> FBTexture[2];
|
std::unique_ptr<FSWSceneTexture> FBTexture[2];
|
||||||
TArray<uint32_t> FBBuffer;
|
|
||||||
int FBTextureIndex = 0;
|
int FBTextureIndex = 0;
|
||||||
bool FBIsTruecolor = false;
|
bool FBIsTruecolor = false;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue