mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-25 21:41:30 +00:00
Minor cleanup in r_swrenderer
This commit is contained in:
parent
d707f1c22e
commit
1b043bb46c
3 changed files with 65 additions and 147 deletions
|
@ -54,6 +54,9 @@
|
||||||
|
|
||||||
void gl_ParseDefs();
|
void gl_ParseDefs();
|
||||||
void gl_InitData();
|
void gl_InitData();
|
||||||
|
void gl_SetActorLights(AActor *);
|
||||||
|
void gl_PreprocessLevel();
|
||||||
|
void gl_CleanLevelData();
|
||||||
|
|
||||||
EXTERN_CVAR(Bool, r_shadercolormaps)
|
EXTERN_CVAR(Bool, r_shadercolormaps)
|
||||||
EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom
|
EXTERN_CVAR(Float, maxviewpitch) // [SP] CVAR from GZDoom
|
||||||
|
@ -82,12 +85,6 @@ FSoftwareRenderer::~FSoftwareRenderer()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// DCanvas :: Init
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::Init()
|
void FSoftwareRenderer::Init()
|
||||||
{
|
{
|
||||||
gl_ParseDefs();
|
gl_ParseDefs();
|
||||||
|
@ -96,38 +93,28 @@ void FSoftwareRenderer::Init()
|
||||||
RenderScene::Instance()->Init();
|
RenderScene::Instance()->Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// DCanvas :: UsesColormap
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
bool FSoftwareRenderer::UsesColormap() const
|
bool FSoftwareRenderer::UsesColormap() const
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Texture precaching
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
|
void FSoftwareRenderer::PrecacheTexture(FTexture *tex, int cache)
|
||||||
{
|
{
|
||||||
|
bool isbgra = screen->IsBgra();
|
||||||
|
|
||||||
if (tex != NULL)
|
if (tex != NULL)
|
||||||
{
|
{
|
||||||
if (cache & FTextureManager::HIT_Columnmode)
|
if (cache & FTextureManager::HIT_Columnmode)
|
||||||
{
|
{
|
||||||
const FTexture::Span *spanp;
|
const FTexture::Span *spanp;
|
||||||
if (r_swtruecolor)
|
if (isbgra)
|
||||||
tex->GetColumnBgra(0, &spanp);
|
tex->GetColumnBgra(0, &spanp);
|
||||||
else
|
else
|
||||||
tex->GetColumn(0, &spanp);
|
tex->GetColumn(0, &spanp);
|
||||||
}
|
}
|
||||||
else if (cache != 0)
|
else if (cache != 0)
|
||||||
{
|
{
|
||||||
if (r_swtruecolor)
|
if (isbgra)
|
||||||
tex->GetPixelsBgra();
|
tex->GetPixelsBgra();
|
||||||
else
|
else
|
||||||
tex->GetPixels ();
|
tex->GetPixels ();
|
||||||
|
@ -188,12 +175,6 @@ void FSoftwareRenderer::Precache(BYTE *texhitlist, TMap<PClassActor*, bool> &act
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Render the view
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::RenderView(player_t *player)
|
void FSoftwareRenderer::RenderView(player_t *player)
|
||||||
{
|
{
|
||||||
if (r_polyrenderer)
|
if (r_polyrenderer)
|
||||||
|
@ -202,7 +183,6 @@ void FSoftwareRenderer::RenderView(player_t *player)
|
||||||
r_swtruecolor = screen->IsBgra();
|
r_swtruecolor = screen->IsBgra();
|
||||||
|
|
||||||
PolyRenderer::Instance()->RenderActorView(player->mo, false);
|
PolyRenderer::Instance()->RenderActorView(player->mo, false);
|
||||||
FCanvasTextureInfo::UpdateAll();
|
|
||||||
|
|
||||||
// Apply special colormap if the target cannot do it
|
// Apply special colormap if the target cannot do it
|
||||||
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||||
|
@ -214,35 +194,31 @@ void FSoftwareRenderer::RenderView(player_t *player)
|
||||||
|
|
||||||
r_swtruecolor = saved_swtruecolor;
|
r_swtruecolor = saved_swtruecolor;
|
||||||
|
|
||||||
return;
|
FCanvasTextureInfo::UpdateAll();
|
||||||
}
|
}
|
||||||
|
else
|
||||||
if (r_swtruecolor != screen->IsBgra())
|
|
||||||
{
|
{
|
||||||
r_swtruecolor = screen->IsBgra();
|
if (r_swtruecolor != screen->IsBgra())
|
||||||
R_InitColumnDrawers();
|
{
|
||||||
|
r_swtruecolor = screen->IsBgra();
|
||||||
|
R_InitColumnDrawers();
|
||||||
|
}
|
||||||
|
|
||||||
|
R_BeginDrawerCommands();
|
||||||
|
RenderScene::Instance()->RenderActorView(player->mo);
|
||||||
|
|
||||||
|
// Apply special colormap if the target cannot do it
|
||||||
|
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
||||||
|
{
|
||||||
|
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(realfixedcolormap, screen);
|
||||||
|
}
|
||||||
|
|
||||||
|
R_EndDrawerCommands();
|
||||||
|
|
||||||
|
FCanvasTextureInfo::UpdateAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
R_BeginDrawerCommands();
|
|
||||||
RenderScene::Instance()->RenderActorView(player->mo);
|
|
||||||
// [RH] Let cameras draw onto textures that were visible this frame.
|
|
||||||
FCanvasTextureInfo::UpdateAll ();
|
|
||||||
|
|
||||||
// Apply special colormap if the target cannot do it
|
|
||||||
if (realfixedcolormap && r_swtruecolor && !(r_shadercolormaps && screen->Accel2D))
|
|
||||||
{
|
|
||||||
DrawerCommandQueue::QueueCommand<ApplySpecialColormapRGBACommand>(realfixedcolormap, screen);
|
|
||||||
}
|
|
||||||
|
|
||||||
R_EndDrawerCommands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::RemapVoxels()
|
void FSoftwareRenderer::RemapVoxels()
|
||||||
{
|
{
|
||||||
for (unsigned i=0; i<Voxels.Size(); i++)
|
for (unsigned i=0; i<Voxels.Size(); i++)
|
||||||
|
@ -251,12 +227,6 @@ void FSoftwareRenderer::RemapVoxels()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Render the view to a savegame picture
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
|
void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int width, int height)
|
||||||
{
|
{
|
||||||
DCanvas *pic = new DSimpleCanvas (width, height, false);
|
DCanvas *pic = new DSimpleCanvas (width, height, false);
|
||||||
|
@ -277,12 +247,6 @@ void FSoftwareRenderer::WriteSavePic (player_t *player, FileWriter *file, int wi
|
||||||
delete pic;
|
delete pic;
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::DrawRemainingPlayerSprites()
|
void FSoftwareRenderer::DrawRemainingPlayerSprites()
|
||||||
{
|
{
|
||||||
if (!r_polyrenderer)
|
if (!r_polyrenderer)
|
||||||
|
@ -295,16 +259,10 @@ void FSoftwareRenderer::DrawRemainingPlayerSprites()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
// Get max. view angle (renderer specific information so it goes here now)
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
#define MAX_DN_ANGLE 56 // Max looking down angle
|
|
||||||
#define MAX_UP_ANGLE 32 // Max looking up angle
|
|
||||||
|
|
||||||
int FSoftwareRenderer::GetMaxViewPitch(bool down)
|
int FSoftwareRenderer::GetMaxViewPitch(bool down)
|
||||||
{
|
{
|
||||||
|
const int MAX_DN_ANGLE = 56; // Max looking down angle
|
||||||
|
const int MAX_UP_ANGLE = 32; // Max looking up angle
|
||||||
return (r_polyrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE);
|
return (r_polyrenderer) ? int(maxviewpitch) : (down ? MAX_DN_ANGLE : MAX_UP_ANGLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,91 +271,48 @@ bool FSoftwareRenderer::RequireGLNodes()
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// OnModeSet
|
|
||||||
//
|
|
||||||
// Called from V_SetResolution()
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::OnModeSet ()
|
void FSoftwareRenderer::OnModeSet ()
|
||||||
{
|
{
|
||||||
RenderScene::Instance()->ScreenResized();
|
RenderScene::Instance()->ScreenResized();
|
||||||
|
|
||||||
RenderTarget = screen;
|
|
||||||
screen->Lock (true);
|
|
||||||
R_SetupBuffer ();
|
|
||||||
screen->Unlock ();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::ErrorCleanup ()
|
void FSoftwareRenderer::ErrorCleanup ()
|
||||||
{
|
{
|
||||||
Clip3DFloors::Instance()->Cleanup();
|
Clip3DFloors::Instance()->Cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::ClearBuffer(int color)
|
void FSoftwareRenderer::ClearBuffer(int color)
|
||||||
{
|
{
|
||||||
// [SP] For now, for truecolor, this just outputs black. We'll figure out how to get something more meaningful
|
|
||||||
// later when this actually matters more. This is just to clear HOMs for now.
|
|
||||||
if (!r_swtruecolor)
|
if (!r_swtruecolor)
|
||||||
|
{
|
||||||
memset(RenderTarget->GetBuffer(), color, RenderTarget->GetPitch() * RenderTarget->GetHeight());
|
memset(RenderTarget->GetBuffer(), color, RenderTarget->GetPitch() * RenderTarget->GetHeight());
|
||||||
|
}
|
||||||
else
|
else
|
||||||
memset(RenderTarget->GetBuffer(), 0, RenderTarget->GetPitch() * RenderTarget->GetHeight() * 4);
|
{
|
||||||
|
uint32_t bgracolor = GPalette.BaseColors[color].d;
|
||||||
|
int size = RenderTarget->GetPitch() * RenderTarget->GetHeight();
|
||||||
|
uint32_t *dest = (uint32_t *)RenderTarget->GetBuffer();
|
||||||
|
for (int i = 0; i < size; i++)
|
||||||
|
dest[i] = bgracolor;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio)
|
void FSoftwareRenderer::SetWindow (int windowSize, int fullWidth, int fullHeight, int stHeight, float trueratio)
|
||||||
{
|
{
|
||||||
R_SWRSetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
|
R_SWRSetWindow(windowSize, fullWidth, fullHeight, stHeight, trueratio);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//===========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::SetupFrame(player_t *player)
|
void FSoftwareRenderer::SetupFrame(player_t *player)
|
||||||
{
|
{
|
||||||
R_SetupColormap(player);
|
R_SetupColormap(player);
|
||||||
R_SetupFreelook();
|
R_SetupFreelook();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
// R_CopyStackedViewParameters
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::CopyStackedViewParameters()
|
void FSoftwareRenderer::CopyStackedViewParameters()
|
||||||
{
|
{
|
||||||
RenderPortal::Instance()->CopyStackedViewParameters();
|
RenderPortal::Instance()->CopyStackedViewParameters();
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//==========================================================================
|
|
||||||
|
|
||||||
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
|
void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov)
|
||||||
{
|
{
|
||||||
BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();
|
BYTE *Pixels = r_swtruecolor ? (BYTE*)tex->GetPixelsBgra() : (BYTE*)tex->GetPixels();
|
||||||
|
@ -410,10 +325,12 @@ void FSoftwareRenderer::RenderTextureView (FCanvasTexture *tex, AActor *viewpoin
|
||||||
|
|
||||||
DAngle savedfov = FieldOfView;
|
DAngle savedfov = FieldOfView;
|
||||||
R_SetFOV ((double)fov);
|
R_SetFOV ((double)fov);
|
||||||
|
|
||||||
if (r_polyrenderer)
|
if (r_polyrenderer)
|
||||||
PolyRenderer::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
PolyRenderer::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||||
else
|
else
|
||||||
RenderScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
RenderScene::Instance()->RenderViewToCanvas(viewpoint, Canvas, 0, 0, tex->GetWidth(), tex->GetHeight(), tex->bFirstUpdate);
|
||||||
|
|
||||||
R_SetFOV (savedfov);
|
R_SetFOV (savedfov);
|
||||||
|
|
||||||
if (Canvas->IsBgra())
|
if (Canvas->IsBgra())
|
||||||
|
@ -473,3 +390,17 @@ sector_t *FSoftwareRenderer::FakeFlat(sector_t *sec, sector_t *tempsec, int *flo
|
||||||
return RenderOpaquePass::Instance()->FakeFlat(sec, tempsec, floorlightlevel, ceilinglightlevel, nullptr, 0, 0, 0, 0);
|
return RenderOpaquePass::Instance()->FakeFlat(sec, tempsec, floorlightlevel, ceilinglightlevel, nullptr, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void FSoftwareRenderer::StateChanged(AActor *actor)
|
||||||
|
{
|
||||||
|
gl_SetActorLights(actor);
|
||||||
|
}
|
||||||
|
|
||||||
|
void FSoftwareRenderer::PreprocessLevel()
|
||||||
|
{
|
||||||
|
gl_PreprocessLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
void FSoftwareRenderer::CleanLevelData()
|
||||||
|
{
|
||||||
|
gl_CleanLevelData();
|
||||||
|
}
|
||||||
|
|
|
@ -1,12 +1,8 @@
|
||||||
#ifndef __R_SWRENDERER_H
|
|
||||||
#define __R_SWRENDERER_H
|
#pragma once
|
||||||
|
|
||||||
#include "r_renderer.h"
|
#include "r_renderer.h"
|
||||||
|
|
||||||
void gl_SetActorLights(AActor *);
|
|
||||||
void gl_PreprocessLevel();
|
|
||||||
void gl_CleanLevelData();
|
|
||||||
|
|
||||||
struct FSoftwareRenderer : public FRenderer
|
struct FSoftwareRenderer : public FRenderer
|
||||||
{
|
{
|
||||||
FSoftwareRenderer();
|
FSoftwareRenderer();
|
||||||
|
@ -44,22 +40,8 @@ struct FSoftwareRenderer : public FRenderer
|
||||||
void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) override;
|
void RenderTextureView (FCanvasTexture *tex, AActor *viewpoint, int fov) override;
|
||||||
sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel) override;
|
sector_t *FakeFlat(sector_t *sec, sector_t *tempsec, int *floorlightlevel, int *ceilinglightlevel) override;
|
||||||
|
|
||||||
void StateChanged(AActor *actor) override
|
void StateChanged(AActor *actor) override;
|
||||||
{
|
void PreprocessLevel() override;
|
||||||
gl_SetActorLights(actor);
|
void CleanLevelData() override;
|
||||||
}
|
|
||||||
|
|
||||||
void PreprocessLevel() override
|
|
||||||
{
|
|
||||||
gl_PreprocessLevel();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CleanLevelData() override
|
|
||||||
{
|
|
||||||
gl_CleanLevelData();
|
|
||||||
}
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
|
@ -188,6 +188,11 @@ namespace swrenderer
|
||||||
void RenderScene::ScreenResized()
|
void RenderScene::ScreenResized()
|
||||||
{
|
{
|
||||||
VisiblePlaneList::Instance()->Init();
|
VisiblePlaneList::Instance()->Init();
|
||||||
|
|
||||||
|
RenderTarget = screen;
|
||||||
|
screen->Lock(true);
|
||||||
|
R_SetupBuffer();
|
||||||
|
screen->Unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
void RenderScene::Init()
|
void RenderScene::Init()
|
||||||
|
|
Loading…
Reference in a new issue