Revert "Merge dpJudas's renderslices branch (#1356)"

This reverts commit a5cba1aba5.
This commit is contained in:
Rachael Alexanderson 2021-03-26 07:08:31 -04:00
commit 6e5dbbc8ec
29 changed files with 1987 additions and 1336 deletions

View file

@ -39,7 +39,7 @@
#include "m_alloc.h"
#include "imagehelpers.h"
#include "texturemanager.h"
#include <mutex>
inline EUpscaleFlags scaleFlagFromUseType(ETextureType useType)
{
@ -119,7 +119,7 @@ void FSoftwareTexture::CalcBitSize ()
//
//==========================================================================
const uint8_t *FSoftwareTexture::GetPixelsLocked(int style)
const uint8_t *FSoftwareTexture::GetPixels(int style)
{
if (Pixels.Size() == 0 || CheckModified(style))
{
@ -158,7 +158,13 @@ const uint8_t *FSoftwareTexture::GetPixelsLocked(int style)
return Pixels.Data();
}
const uint32_t *FSoftwareTexture::GetPixelsBgraLocked()
//==========================================================================
//
//
//
//==========================================================================
const uint32_t *FSoftwareTexture::GetPixelsBgra()
{
if (PixelsBgra.Size() == 0 || CheckModified(2))
{
@ -191,31 +197,60 @@ const uint32_t *FSoftwareTexture::GetPixelsBgraLocked()
//
//==========================================================================
int FSoftwareTexture::CurrentUpdate = 0;
namespace swrenderer { extern std::mutex loadmutex; }
void FSoftwareTexture::UpdatePixels(int index)
const uint8_t *FSoftwareTexture::GetColumn(int index, unsigned int column, const FSoftwareTextureSpan **spans_out)
{
std::unique_lock<std::mutex> lock(swrenderer::loadmutex);
if (Unlockeddata[index].LastUpdate != CurrentUpdate)
auto Pixeldata = GetPixels(index);
if ((unsigned)column >= (unsigned)GetPhysicalWidth())
{
if (index != 2)
if (WidthMask + 1 == GetPhysicalWidth())
{
const uint8_t* Pixeldata = GetPixelsLocked(index);
if (Spandata[index] == nullptr)
Spandata[index] = CreateSpans(Pixeldata);
Unlockeddata[index].Pixels = Pixeldata;
Unlockeddata[index].LastUpdate = CurrentUpdate;
column &= WidthMask;
}
else
{
const uint32_t* Pixeldata = GetPixelsBgraLocked();
if (Spandata[index] == nullptr)
Spandata[index] = CreateSpans(Pixeldata);
Unlockeddata[index].Pixels = Pixeldata;
Unlockeddata[index].LastUpdate = CurrentUpdate;
column %= GetPhysicalWidth();
}
}
if (spans_out != nullptr)
{
if (Spandata[index] == nullptr)
{
Spandata[index] = CreateSpans(Pixeldata);
}
*spans_out = Spandata[index][column];
}
return Pixeldata + column * GetPhysicalHeight();
}
//==========================================================================
//
//
//
//==========================================================================
const uint32_t *FSoftwareTexture::GetColumnBgra(unsigned int column, const FSoftwareTextureSpan **spans_out)
{
auto Pixeldata = GetPixelsBgra();
if ((unsigned)column >= (unsigned)GetPhysicalWidth())
{
if (WidthMask + 1 == GetPhysicalWidth())
{
column &= WidthMask;
}
else
{
column %= GetPhysicalWidth();
}
}
if (spans_out != nullptr)
{
if (Spandata[2] == nullptr)
{
Spandata[2] = CreateSpans(Pixeldata);
}
*spans_out = Spandata[2][column];
}
return Pixeldata + column * GetPhysicalHeight();
}
//==========================================================================
@ -527,23 +562,15 @@ void FSoftwareTexture::FreeAllSpans()
}
}
// Note: this function needs to be thread safe
FSoftwareTexture* GetSoftwareTexture(FGameTexture* tex)
{
FSoftwareTexture* SoftwareTexture = static_cast<FSoftwareTexture*>(tex->GetSoftwareTexture());
if (!SoftwareTexture)
{
static std::mutex loadmutex;
std::unique_lock<std::mutex> lock(loadmutex);
SoftwareTexture = static_cast<FSoftwareTexture*>(tex->GetSoftwareTexture());
if (!SoftwareTexture)
{
if (tex->isSoftwareCanvas()) SoftwareTexture = new FSWCanvasTexture(tex);
else if (tex->isWarped()) SoftwareTexture = new FWarpTexture(tex, tex->isWarped());
else SoftwareTexture = new FSoftwareTexture(tex);
tex->SetSoftwareTexture(SoftwareTexture);
}
if (tex->isSoftwareCanvas()) SoftwareTexture = new FSWCanvasTexture(tex);
else if (tex->isWarped()) SoftwareTexture = new FWarpTexture(tex, tex->isWarped());
else SoftwareTexture = new FSoftwareTexture(tex);
tex->SetSoftwareTexture(SoftwareTexture);
}
return SoftwareTexture;
}
@ -555,7 +582,6 @@ CUSTOM_CVAR(Bool, vid_nopalsubstitutions, false, CVAR_ARCHIVE | CVAR_NOINITCALL)
R_InitSkyMap();
}
// Note: this function needs to be thread safe
FSoftwareTexture* GetPalettedSWTexture(FTextureID texid, bool animate, bool checkcompat, bool allownull)
{
bool needpal = !vid_nopalsubstitutions && !V_IsTrueColor();