mirror of
https://github.com/ZDoom/raze-gles.git
synced 2024-12-29 04:50:42 +00:00
- backend sync with GZDoom.
This commit is contained in:
parent
bd0c8acd46
commit
c26b6cdf59
19 changed files with 44 additions and 44 deletions
|
@ -5346,6 +5346,7 @@ void rotatesprite_(int32_t sx, int32_t sy, int32_t z, int16_t a, int16_t picnum,
|
||||||
|
|
||||||
void videoInit()
|
void videoInit()
|
||||||
{
|
{
|
||||||
|
lookups.postLoadLookups();
|
||||||
V_Init2();
|
V_Init2();
|
||||||
videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1);
|
videoSetGameMode(vid_fullscreen, SCREENWIDTH, SCREENHEIGHT, 32, 1);
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,6 @@ OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, bool fullscreen) :
|
||||||
FHardwareTexture::InitGlobalState();
|
FHardwareTexture::InitGlobalState();
|
||||||
|
|
||||||
// Make sure all global variables tracking OpenGL context state are reset..
|
// Make sure all global variables tracking OpenGL context state are reset..
|
||||||
|
|
||||||
gl_RenderState.Reset();
|
gl_RenderState.Reset();
|
||||||
|
|
||||||
GLRenderer = nullptr;
|
GLRenderer = nullptr;
|
||||||
|
@ -266,6 +265,7 @@ void OpenGLFrameBuffer::Swap()
|
||||||
Finish.Unclock();
|
Finish.Unclock();
|
||||||
camtexcount = 0;
|
camtexcount = 0;
|
||||||
FHardwareTexture::UnbindAll();
|
FHardwareTexture::UnbindAll();
|
||||||
|
gl_RenderState.ClearLastMaterial();
|
||||||
mDebug->Update();
|
mDebug->Update();
|
||||||
mVertexData->Reset();
|
mVertexData->Reset();
|
||||||
}
|
}
|
||||||
|
@ -296,16 +296,15 @@ void OpenGLFrameBuffer::SetVSync(bool vsync)
|
||||||
//
|
//
|
||||||
//===========================================================================
|
//===========================================================================
|
||||||
|
|
||||||
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(int numchannels)
|
|
||||||
{
|
|
||||||
return new FHardwareTexture(numchannels);
|
|
||||||
}
|
|
||||||
|
|
||||||
void OpenGLFrameBuffer::SetTextureFilterMode()
|
void OpenGLFrameBuffer::SetTextureFilterMode()
|
||||||
{
|
{
|
||||||
if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
if (GLRenderer != nullptr && GLRenderer->mSamplerManager != nullptr) GLRenderer->mSamplerManager->SetTextureFilterMode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IHardwareTexture *OpenGLFrameBuffer::CreateHardwareTexture(int numchannels)
|
||||||
|
{
|
||||||
|
return new FHardwareTexture(numchannels);
|
||||||
|
}
|
||||||
|
|
||||||
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
{
|
{
|
||||||
|
@ -326,6 +325,7 @@ void OpenGLFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
}
|
}
|
||||||
// unbind everything.
|
// unbind everything.
|
||||||
FHardwareTexture::UnbindAll();
|
FHardwareTexture::UnbindAll();
|
||||||
|
gl_RenderState.ClearLastMaterial();
|
||||||
}
|
}
|
||||||
|
|
||||||
IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer()
|
IVertexBuffer *OpenGLFrameBuffer::CreateVertexBuffer()
|
||||||
|
|
|
@ -40,8 +40,8 @@ public:
|
||||||
FRenderState* RenderState() override;
|
FRenderState* RenderState() override;
|
||||||
void UpdatePalette() override;
|
void UpdatePalette() override;
|
||||||
const char* DeviceName() const override;
|
const char* DeviceName() const override;
|
||||||
IHardwareTexture *CreateHardwareTexture(int numchannels) override;
|
|
||||||
void SetTextureFilterMode() override;
|
void SetTextureFilterMode() override;
|
||||||
|
IHardwareTexture *CreateHardwareTexture(int numchannels) override;
|
||||||
void PrecacheMaterial(FMaterial *mat, int translation) override;
|
void PrecacheMaterial(FMaterial *mat, int translation) override;
|
||||||
void BeginFrame() override;
|
void BeginFrame() override;
|
||||||
void SetViewportRects(IntRect *bounds) override;
|
void SetViewportRects(IntRect *bounds) override;
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#ifndef __GL_SAMPLERS_H
|
#ifndef __GL_SAMPLERS_H
|
||||||
#define __GL_SAMPLERS_H
|
#define __GL_SAMPLERS_H
|
||||||
|
|
||||||
|
#include "gl_hwtexture.h"
|
||||||
#include "textures.h"
|
#include "textures.h"
|
||||||
|
|
||||||
namespace OpenGLRenderer
|
namespace OpenGLRenderer
|
||||||
|
|
|
@ -379,14 +379,16 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
|
vp_comb << "#define SUPPORTS_SHADOWMAPS\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
vp_comb << defines << i_data.GetChars();
|
|
||||||
FString fp_comb = vp_comb;
|
FString fp_comb = vp_comb;
|
||||||
|
vp_comb << defines << i_data.GetChars();
|
||||||
|
fp_comb << "$placeholder$\n" << defines << i_data.GetChars();
|
||||||
|
|
||||||
vp_comb << "#line 1\n";
|
vp_comb << "#line 1\n";
|
||||||
fp_comb << "#line 1\n";
|
fp_comb << "#line 1\n";
|
||||||
|
|
||||||
vp_comb << RemoveLayoutLocationDecl(vp_data.GetString(), "out").GetChars() << "\n";
|
vp_comb << RemoveLayoutLocationDecl(vp_data.GetString(), "out").GetChars() << "\n";
|
||||||
fp_comb << RemoveLayoutLocationDecl(fp_data.GetString(), "in").GetChars() << "\n";
|
fp_comb << RemoveLayoutLocationDecl(fp_data.GetString(), "in").GetChars() << "\n";
|
||||||
|
FString placeholder = "\n";
|
||||||
|
|
||||||
if (proc_prog_lump != NULL)
|
if (proc_prog_lump != NULL)
|
||||||
{
|
{
|
||||||
|
@ -448,9 +450,8 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
if (pp_data.GetString().IndexOf("ProcessMaterial") >= 0 && pp_data.GetString().IndexOf("SetupMaterial") < 0)
|
if (pp_data.GetString().IndexOf("ProcessMaterial") >= 0 && pp_data.GetString().IndexOf("SetupMaterial") < 0)
|
||||||
{
|
{
|
||||||
// This reactivates the old logic and disables all features that cannot be supported with that method.
|
// This reactivates the old logic and disables all features that cannot be supported with that method.
|
||||||
fp_comb.Insert(0, "#define LEGACY_USER_SHADER\n");
|
placeholder << "#define LEGACY_USER_SHADER\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -458,6 +459,7 @@ bool FShader::Load(const char * name, const char * vert_prog_lump, const char *
|
||||||
fp_comb << proc_prog_lump + 1;
|
fp_comb << proc_prog_lump + 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
fp_comb.Substitute("$placeholder$", placeholder);
|
||||||
|
|
||||||
if (light_fragprog)
|
if (light_fragprog)
|
||||||
{
|
{
|
||||||
|
|
|
@ -305,8 +305,8 @@ public:
|
||||||
FShader *BindEffect(int effect, EPassType passType);
|
FShader *BindEffect(int effect, EPassType passType);
|
||||||
FShader *Get(unsigned int eff, bool alphateston, EPassType passType);
|
FShader *Get(unsigned int eff, bool alphateston, EPassType passType);
|
||||||
|
|
||||||
private:
|
|
||||||
void SetActiveShader(FShader *sh);
|
void SetActiveShader(FShader *sh);
|
||||||
|
private:
|
||||||
|
|
||||||
FShader *mActiveShader = nullptr;
|
FShader *mActiveShader = nullptr;
|
||||||
TArray<FShaderCollection*> mPassShaders;
|
TArray<FShaderCollection*> mPassShaders;
|
||||||
|
|
|
@ -305,7 +305,7 @@ void PolyFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IHardwareTexture *PolyFrameBuffer::CreateHardwareTexture(int)
|
IHardwareTexture *PolyFrameBuffer::CreateHardwareTexture(int numchannels)
|
||||||
{
|
{
|
||||||
return new PolyHardwareTexture();
|
return new PolyHardwareTexture();
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ public:
|
||||||
void AmbientOccludeScene(float m5) override;
|
void AmbientOccludeScene(float m5) override;
|
||||||
//void SetSceneRenderTarget(bool useSSAO) override;
|
//void SetSceneRenderTarget(bool useSSAO) override;
|
||||||
|
|
||||||
IHardwareTexture *CreateHardwareTexture(int) override;
|
IHardwareTexture *CreateHardwareTexture(int numchannels) override;
|
||||||
IVertexBuffer *CreateVertexBuffer() override;
|
IVertexBuffer *CreateVertexBuffer() override;
|
||||||
IIndexBuffer *CreateIndexBuffer() override;
|
IIndexBuffer *CreateIndexBuffer() override;
|
||||||
IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) override;
|
IDataBuffer *CreateDataBuffer(int bindingpoint, bool ssbo, bool needsresize) override;
|
||||||
|
|
|
@ -104,7 +104,7 @@ public:
|
||||||
FVector3 u = normalize3(eyeCoordPos);
|
FVector3 u = normalize3(eyeCoordPos);
|
||||||
FVector3 n = normalize3(mul(Viewpoint->mNormalViewMatrix, FVector4(parmTexCoord.X, 0.0f, parmTexCoord.Y, 0.0f)));
|
FVector3 n = normalize3(mul(Viewpoint->mNormalViewMatrix, FVector4(parmTexCoord.X, 0.0f, parmTexCoord.Y, 0.0f)));
|
||||||
FVector3 r = reflect(u, n);
|
FVector3 r = reflect(u, n);
|
||||||
float m = 2.0f * sqrt(r.X*r.X + r.Y*r.Y + (r.Z + 1.0f)*(r.Z + 1.0f));
|
float m = 2.0f * sqrtf(r.X*r.X + r.Y*r.Y + (r.Z + 1.0f)*(r.Z + 1.0f));
|
||||||
vTexCoord.X = r.X / m + 0.5f;
|
vTexCoord.X = r.X / m + 0.5f;
|
||||||
vTexCoord.Y = r.Y / m + 0.5f;
|
vTexCoord.Y = r.Y / m + 0.5f;
|
||||||
}
|
}
|
||||||
|
@ -138,13 +138,13 @@ public:
|
||||||
private:
|
private:
|
||||||
static FVector3 normalize(const FVector3 &a)
|
static FVector3 normalize(const FVector3 &a)
|
||||||
{
|
{
|
||||||
float rcplen = 1.0f / sqrt(a.X * a.X + a.Y * a.Y + a.Z * a.Z);
|
float rcplen = 1.0f / sqrtf(a.X * a.X + a.Y * a.Y + a.Z * a.Z);
|
||||||
return FVector3(a.X * rcplen, a.Y * rcplen, a.Z * rcplen);
|
return FVector3(a.X * rcplen, a.Y * rcplen, a.Z * rcplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static FVector3 normalize3(const FVector4 &a)
|
static FVector3 normalize3(const FVector4 &a)
|
||||||
{
|
{
|
||||||
float rcplen = 1.0f / sqrt(a.X * a.X + a.Y * a.Y + a.Z * a.Z);
|
float rcplen = 1.0f / sqrtf(a.X * a.X + a.Y * a.Y + a.Z * a.Z);
|
||||||
return FVector3(a.X * rcplen, a.Y * rcplen, a.Z * rcplen);
|
return FVector3(a.X * rcplen, a.Y * rcplen, a.Z * rcplen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -72,7 +72,6 @@ EXTERN_CVAR(Int, screenblocks)
|
||||||
|
|
||||||
DFrameBuffer::DFrameBuffer (int width, int height)
|
DFrameBuffer::DFrameBuffer (int width, int height)
|
||||||
{
|
{
|
||||||
twod = &m2DDrawer;
|
|
||||||
SetSize(width, height);
|
SetSize(width, height);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,6 @@
|
||||||
#include "i_interface.h"
|
#include "i_interface.h"
|
||||||
#include "v_draw.h"
|
#include "v_draw.h"
|
||||||
#include "templates.h"
|
#include "templates.h"
|
||||||
#include "palette.h"
|
|
||||||
|
|
||||||
EXTERN_CVAR(Int, menu_resolution_custom_width)
|
EXTERN_CVAR(Int, menu_resolution_custom_width)
|
||||||
EXTERN_CVAR(Int, menu_resolution_custom_height)
|
EXTERN_CVAR(Int, menu_resolution_custom_height)
|
||||||
|
@ -290,6 +289,9 @@ void V_UpdateModeSize (int width, int height)
|
||||||
void V_OutputResized (int width, int height)
|
void V_OutputResized (int width, int height)
|
||||||
{
|
{
|
||||||
V_UpdateModeSize(width, height);
|
V_UpdateModeSize(width, height);
|
||||||
|
// set new resolution in 2D drawer
|
||||||
|
twod->Begin(screen->GetWidth(), screen->GetHeight());
|
||||||
|
twod->End();
|
||||||
setsizeneeded = true;
|
setsizeneeded = true;
|
||||||
C_NewModeAdjust();
|
C_NewModeAdjust();
|
||||||
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
|
if (sysCallbacks && sysCallbacks->OnScreenSizeChanged)
|
||||||
|
@ -358,8 +360,6 @@ void V_InitScreen()
|
||||||
|
|
||||||
void V_Init2()
|
void V_Init2()
|
||||||
{
|
{
|
||||||
lookups.postLoadLookups();
|
|
||||||
|
|
||||||
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
|
float gamma = static_cast<DDummyFrameBuffer *>(screen)->Gamma;
|
||||||
|
|
||||||
{
|
{
|
||||||
|
@ -396,7 +396,10 @@ CUSTOM_CVAR (Int, vid_aspect, 0, CVAR_GLOBALCONFIG|CVAR_ARCHIVE)
|
||||||
sysCallbacks->OnScreenSizeChanged();
|
sysCallbacks->OnScreenSizeChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION(_Screen, GetAspectRatio)
|
||||||
|
{
|
||||||
|
ACTION_RETURN_FLOAT(ActiveRatio(screen->GetWidth(), screen->GetHeight(), nullptr));
|
||||||
|
}
|
||||||
|
|
||||||
CCMD(vid_setsize)
|
CCMD(vid_setsize)
|
||||||
{
|
{
|
||||||
|
|
|
@ -120,14 +120,11 @@ protected:
|
||||||
};
|
};
|
||||||
|
|
||||||
class IHardwareTexture;
|
class IHardwareTexture;
|
||||||
class FGameTexture;
|
class FTexture;
|
||||||
|
|
||||||
|
|
||||||
class DFrameBuffer
|
class DFrameBuffer
|
||||||
{
|
{
|
||||||
protected:
|
|
||||||
|
|
||||||
F2DDrawer m2DDrawer;
|
|
||||||
private:
|
private:
|
||||||
int Width = 0;
|
int Width = 0;
|
||||||
int Height = 0;
|
int Height = 0;
|
||||||
|
@ -202,7 +199,6 @@ public:
|
||||||
virtual void SetTextureFilterMode() {}
|
virtual void SetTextureFilterMode() {}
|
||||||
virtual IHardwareTexture *CreateHardwareTexture(int numchannels) { return nullptr; }
|
virtual IHardwareTexture *CreateHardwareTexture(int numchannels) { return nullptr; }
|
||||||
virtual void PrecacheMaterial(FMaterial *mat, int translation) {}
|
virtual void PrecacheMaterial(FMaterial *mat, int translation) {}
|
||||||
virtual FModelRenderer *CreateModelRenderer(int mli) { return nullptr; }
|
|
||||||
virtual FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags);
|
virtual FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags);
|
||||||
virtual void BeginFrame() {}
|
virtual void BeginFrame() {}
|
||||||
virtual void SetWindowSize(int w, int h) {}
|
virtual void SetWindowSize(int w, int h) {}
|
||||||
|
|
|
@ -284,8 +284,10 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
|
||||||
{
|
{
|
||||||
FString code = GetTargetGlslVersion();
|
FString code = GetTargetGlslVersion();
|
||||||
code << defines;
|
code << defines;
|
||||||
|
code << "\n$placeholder$"; // here the code can later add more needed #defines.
|
||||||
code << "\n#define MAX_STREAM_DATA " << std::to_string(MAX_STREAM_DATA).c_str() << "\n";
|
code << "\n#define MAX_STREAM_DATA " << std::to_string(MAX_STREAM_DATA).c_str() << "\n";
|
||||||
code << shaderBindings;
|
code << shaderBindings;
|
||||||
|
FString placeholder = "\n";
|
||||||
|
|
||||||
if (!device->UsedDeviceFeatures.shaderClipDistance) code << "#define NO_CLIPDISTANCE_SUPPORT\n";
|
if (!device->UsedDeviceFeatures.shaderClipDistance) code << "#define NO_CLIPDISTANCE_SUPPORT\n";
|
||||||
if (!alphatest) code << "#define NO_ALPHATEST\n";
|
if (!alphatest) code << "#define NO_ALPHATEST\n";
|
||||||
|
@ -342,7 +344,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
|
||||||
if (pp_code.IndexOf("ProcessMaterial") >= 0 && pp_code.IndexOf("SetupMaterial") < 0)
|
if (pp_code.IndexOf("ProcessMaterial") >= 0 && pp_code.IndexOf("SetupMaterial") < 0)
|
||||||
{
|
{
|
||||||
// This reactivates the old logic and disables all features that cannot be supported with that method.
|
// This reactivates the old logic and disables all features that cannot be supported with that method.
|
||||||
code.Insert(0, "#define LEGACY_USER_SHADER\n");
|
placeholder << "#define LEGACY_USER_SHADER\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -351,6 +353,7 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
|
||||||
code << (material_lump + 1) << "\n";
|
code << (material_lump + 1) << "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
code.Substitute("$placeholder$", placeholder);
|
||||||
|
|
||||||
if (light_lump)
|
if (light_lump)
|
||||||
{
|
{
|
||||||
|
|
|
@ -379,7 +379,7 @@ void VulkanFrameBuffer::PrecacheMaterial(FMaterial *mat, int translation)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture()
|
IHardwareTexture *VulkanFrameBuffer::CreateHardwareTexture(int numchannels)
|
||||||
{
|
{
|
||||||
return new VkHardwareTexture();
|
return new VkHardwareTexture();
|
||||||
}
|
}
|
||||||
|
@ -419,11 +419,6 @@ IDataBuffer *VulkanFrameBuffer::CreateDataBuffer(int bindingpoint, bool ssbo, bo
|
||||||
}
|
}
|
||||||
|
|
||||||
void VulkanFrameBuffer::SetTextureFilterMode()
|
void VulkanFrameBuffer::SetTextureFilterMode()
|
||||||
{
|
|
||||||
TextureFilterChanged();
|
|
||||||
}
|
|
||||||
|
|
||||||
void VulkanFrameBuffer::TextureFilterChanged()
|
|
||||||
{
|
{
|
||||||
if (mSamplerManager)
|
if (mSamplerManager)
|
||||||
{
|
{
|
||||||
|
|
|
@ -77,7 +77,6 @@ public:
|
||||||
const char* DeviceName() const override;
|
const char* DeviceName() const override;
|
||||||
int Backend() override { return 1; }
|
int Backend() override { return 1; }
|
||||||
void SetTextureFilterMode() override;
|
void SetTextureFilterMode() override;
|
||||||
void TextureFilterChanged() override;
|
|
||||||
void StartPrecaching() override;
|
void StartPrecaching() override;
|
||||||
void BeginFrame() override;
|
void BeginFrame() override;
|
||||||
void BlurScene(float amount) override;
|
void BlurScene(float amount) override;
|
||||||
|
@ -89,7 +88,7 @@ public:
|
||||||
void ImageTransitionScene(bool unknown) override;
|
void ImageTransitionScene(bool unknown) override;
|
||||||
void SetActiveRenderTarget() override;
|
void SetActiveRenderTarget() override;
|
||||||
|
|
||||||
IHardwareTexture *CreateHardwareTexture() override;
|
IHardwareTexture *CreateHardwareTexture(int numchannels) override;
|
||||||
FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags) override;
|
FMaterial* CreateMaterial(FGameTexture* tex, int scaleflags) override;
|
||||||
IVertexBuffer *CreateVertexBuffer() override;
|
IVertexBuffer *CreateVertexBuffer() override;
|
||||||
IIndexBuffer *CreateIndexBuffer() override;
|
IIndexBuffer *CreateIndexBuffer() override;
|
||||||
|
|
|
@ -369,7 +369,8 @@ VulkanDescriptorSet* VkMaterial::GetDescriptorSet(const FMaterialState& state)
|
||||||
int translation = state.mTranslation;
|
int translation = state.mTranslation;
|
||||||
|
|
||||||
auto remap = translation <= 0 ? nullptr : GPalette.TranslationToTable(translation);
|
auto remap = translation <= 0 ? nullptr : GPalette.TranslationToTable(translation);
|
||||||
if (remap) translation = remap->Index;
|
if (remap)
|
||||||
|
translation = remap->Index;
|
||||||
|
|
||||||
clampmode = base->GetClampMode(clampmode);
|
clampmode = base->GetClampMode(clampmode);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue