mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-13 07:57:52 +00:00
- use FShaderProgram through an abstract interface and remove all dependencies on the GL renderer from the shader definition source files.
This commit is contained in:
parent
8bf009bd89
commit
3401876476
30 changed files with 190 additions and 158 deletions
|
@ -30,6 +30,7 @@
|
||||||
#include "gl/dynlights/gl_lightbuffer.h"
|
#include "gl/dynlights/gl_lightbuffer.h"
|
||||||
#include "hwrenderer/utility/hw_clock.h"
|
#include "hwrenderer/utility/hw_clock.h"
|
||||||
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
#include "hwrenderer/dynlights/hw_dynlightdata.h"
|
||||||
|
#include "hwrenderer/data/shaderuniforms.h"
|
||||||
|
|
||||||
static const int INITIAL_BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB.
|
static const int INITIAL_BUFFER_SIZE = 160000; // This means 80000 lights per frame and 160000*16 bytes == 2.56 MB.
|
||||||
|
|
||||||
|
|
|
@ -20,10 +20,9 @@
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
#include "gl/shaders/gl_ambientshader.h"
|
#include "gl_ambientshader.h"
|
||||||
|
|
||||||
void FLinearDepthShader::Bind(IRenderQueue *q)
|
void FLinearDepthShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
|
@ -36,9 +35,9 @@ void FLinearDepthShader::Bind(IRenderQueue *q)
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
if (multisample) prolog += "#define MULTISAMPLE\n";
|
if (multisample) prolog += "#define MULTISAMPLE\n";
|
||||||
|
|
||||||
mShader.reset(new FShaderProgram());
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/lineardepth.fp", prolog, 330);
|
||||||
mShader->Link("shaders/glsl/lineardepth");
|
mShader->Link("shaders/glsl/lineardepth");
|
||||||
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
|
@ -58,9 +57,9 @@ void FSSAOShader::Bind(IRenderQueue *q)
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
prolog += GetDefines(gl_ssao, multisample);
|
prolog += GetDefines(gl_ssao, multisample);
|
||||||
|
|
||||||
mShader.reset(new FShaderProgram());
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssao.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/ssao.fp", prolog, 330);
|
||||||
mShader->Link("shaders/glsl/ssao");
|
mShader->Link("shaders/glsl/ssao");
|
||||||
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
|
@ -105,13 +104,14 @@ void FDepthBlurShader::Bind(IRenderQueue *q, bool vertical)
|
||||||
else
|
else
|
||||||
prolog += "#define BLUR_HORIZONTAL\n";
|
prolog += "#define BLUR_HORIZONTAL\n";
|
||||||
|
|
||||||
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
shader.reset(screen->CreateShaderProgram());
|
||||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/depthblur.fp", prolog, 330);
|
shader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
shader.Link("shaders/glsl/depthblur");
|
shader->Compile(IShaderProgram::Fragment, "shaders/glsl/depthblur.fp", prolog, 330);
|
||||||
shader.SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms");
|
shader->Link("shaders/glsl/depthblur");
|
||||||
|
shader->SetUniformBufferLocation(Uniforms[vertical].BindingPoint(), "Uniforms");
|
||||||
Uniforms[vertical].Init();
|
Uniforms[vertical].Init();
|
||||||
}
|
}
|
||||||
shader.Bind(q);
|
shader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FSSAOCombineShader::Bind(IRenderQueue *q)
|
void FSSAOCombineShader::Bind(IRenderQueue *q)
|
||||||
|
@ -126,9 +126,9 @@ void FSSAOCombineShader::Bind(IRenderQueue *q)
|
||||||
if (multisample)
|
if (multisample)
|
||||||
prolog += "#define MULTISAMPLE\n";
|
prolog += "#define MULTISAMPLE\n";
|
||||||
|
|
||||||
mShader.reset(new FShaderProgram());
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader->Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader->Compile(FShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/ssaocombine.fp", prolog, 330);
|
||||||
mShader->Link("shaders/glsl/ssaocombine");
|
mShader->Link("shaders/glsl/ssaocombine");
|
||||||
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
|
|
|
@ -1,9 +1,7 @@
|
||||||
#ifndef __GL_AMBIENTSHADER_H
|
#ifndef __GL_AMBIENTSHADER_H
|
||||||
#define __GL_AMBIENTSHADER_H
|
#define __GL_AMBIENTSHADER_H
|
||||||
|
|
||||||
#include <memory>
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
|
||||||
|
|
||||||
class FLinearDepthShader
|
class FLinearDepthShader
|
||||||
{
|
{
|
||||||
|
@ -42,7 +40,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<FShaderProgram> mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
bool mMultisample = false;
|
bool mMultisample = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -101,7 +99,7 @@ private:
|
||||||
|
|
||||||
FString GetDefines(int mode, bool multisample);
|
FString GetDefines(int mode, bool multisample);
|
||||||
|
|
||||||
std::unique_ptr<FShaderProgram> mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
Quality mCurrentQuality = Off;
|
Quality mCurrentQuality = Off;
|
||||||
bool mMultisample = false;
|
bool mMultisample = false;
|
||||||
};
|
};
|
||||||
|
@ -131,7 +129,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms[2];
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms[2];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader[2];
|
std::unique_ptr<IShaderProgram> mShader[2];
|
||||||
};
|
};
|
||||||
|
|
||||||
class FSSAOCombineShader
|
class FSSAOCombineShader
|
||||||
|
@ -163,7 +161,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::unique_ptr<FShaderProgram> mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
bool mMultisample = false;
|
bool mMultisample = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "gl/shaders/gl_bloomshader.h"
|
#include "gl/shaders/gl_bloomshader.h"
|
||||||
|
|
||||||
|
@ -35,22 +34,24 @@ void FBloomExtractShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/bloomextract");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/bloomextract.fp", prolog, 330);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/bloomextract");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FBloomCombineShader::Bind(IRenderQueue *q)
|
void FBloomCombineShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
if (!mShader)
|
if (!mShader)
|
||||||
{
|
{
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/bloomcombine");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/bloomcombine.fp", "", 330);
|
||||||
|
mShader->Link("shaders/glsl/bloomcombine");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_BLOOMSHADER_H
|
#ifndef __GL_BLOOMSHADER_H
|
||||||
#define __GL_BLOOMSHADER_H
|
#define __GL_BLOOMSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FBloomExtractShader
|
class FBloomExtractShader
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FBloomCombineShader
|
class FBloomCombineShader
|
||||||
|
@ -35,7 +35,7 @@ public:
|
||||||
void Bind(IRenderQueue *q);
|
void Bind(IRenderQueue *q);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -25,12 +25,8 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "gl/shaders/gl_blurshader.h"
|
#include "gl/shaders/gl_blurshader.h"
|
||||||
#include "gl/data/gl_vertexbuffer.h"
|
|
||||||
#include "gl/renderer/gl_renderer.h"
|
|
||||||
#include "gl/renderer/gl_renderbuffers.h"
|
|
||||||
|
|
||||||
void FBlurShader::Bind(IRenderQueue *q, bool vertical)
|
void FBlurShader::Bind(IRenderQueue *q, bool vertical)
|
||||||
{
|
{
|
||||||
|
@ -42,12 +38,13 @@ void FBlurShader::Bind(IRenderQueue *q, bool vertical)
|
||||||
else
|
else
|
||||||
prolog += "#define BLUR_HORIZONTAL\n";
|
prolog += "#define BLUR_HORIZONTAL\n";
|
||||||
|
|
||||||
mShader[vertical].Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader[vertical].reset(screen->CreateShaderProgram());
|
||||||
mShader[vertical].Compile(FShaderProgram::Fragment, "shaders/glsl/blur.fp", prolog, 330);
|
mShader[vertical]->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader[vertical].Link("shaders/glsl/blur");
|
mShader[vertical]->Compile(IShaderProgram::Fragment, "shaders/glsl/blur.fp", prolog, 330);
|
||||||
mShader[vertical].SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
mShader[vertical]->Link("shaders/glsl/blur");
|
||||||
|
mShader[vertical]->SetUniformBufferLocation(POSTPROCESS_BINDINGPOINT, "Uniforms");
|
||||||
Uniforms[vertical].Init();
|
Uniforms[vertical].Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
mShader[vertical].Bind(q);
|
mShader[vertical]->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,8 +1,7 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
#include <memory>
|
|
||||||
|
|
||||||
class FGLRenderer;
|
class FGLRenderer;
|
||||||
class PPFrameBuffer;
|
class PPFrameBuffer;
|
||||||
|
@ -36,5 +35,5 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms[2];
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms[2];
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader[2];
|
std::unique_ptr<IShaderProgram> mShader[2];
|
||||||
};
|
};
|
||||||
|
|
|
@ -25,22 +25,21 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "gl/shaders/gl_colormapshader.h"
|
#include "gl/shaders/gl_colormapshader.h"
|
||||||
|
|
||||||
void FColormapShader::Bind(IRenderQueue *q)
|
void FColormapShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
auto &shader = mShader;
|
if (!mShader)
|
||||||
if (!shader)
|
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/colormap.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
shader.Link("shaders/glsl/colormap");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/colormap.fp", prolog, 330);
|
||||||
shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/colormap");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
shader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_COLORMAPSHADER_H
|
#ifndef __GL_COLORMAPSHADER_H
|
||||||
#define __GL_COLORMAPSHADER_H
|
#define __GL_COLORMAPSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FColormapShader
|
class FColormapShader
|
||||||
{
|
{
|
||||||
|
@ -27,7 +27,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -24,7 +24,6 @@
|
||||||
// Fast approXimate Anti-Aliasing (FXAA) post-processing
|
// Fast approXimate Anti-Aliasing (FXAA) post-processing
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "gl/shaders/gl_fxaashader.h"
|
#include "gl/shaders/gl_fxaashader.h"
|
||||||
|
|
||||||
EXTERN_CVAR(Int, gl_fxaa)
|
EXTERN_CVAR(Int, gl_fxaa)
|
||||||
|
@ -33,17 +32,18 @@ void FFXAALumaShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
if (!mShader)
|
if (!mShader)
|
||||||
{
|
{
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", "#define FXAA_LUMA_PASS\n", 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/fxaa");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/fxaa.fp", "#define FXAA_LUMA_PASS\n", 330);
|
||||||
|
mShader->Link("shaders/glsl/fxaa");
|
||||||
}
|
}
|
||||||
|
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetMaxVersion()
|
static int GetMaxVersion()
|
||||||
{
|
{
|
||||||
return gl.glslversion >= 4.f ? 400 : 330;
|
return screen->glslversion >= 4.f ? 400 : 330;
|
||||||
}
|
}
|
||||||
|
|
||||||
static FString GetDefines()
|
static FString GetDefines()
|
||||||
|
@ -76,19 +76,20 @@ static FString GetDefines()
|
||||||
void FFXAAShader::Bind(IRenderQueue *q)
|
void FFXAAShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
assert(gl_fxaa > 0 && gl_fxaa < Count);
|
assert(gl_fxaa > 0 && gl_fxaa < Count);
|
||||||
FShaderProgram &shader = mShaders[gl_fxaa];
|
auto &shader = mShaders[gl_fxaa];
|
||||||
|
|
||||||
if (!shader)
|
if (!shader)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc()) + GetDefines();
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc()) + GetDefines();
|
||||||
const int maxVersion = GetMaxVersion();
|
const int maxVersion = GetMaxVersion();
|
||||||
|
|
||||||
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
shader.reset(screen->CreateShaderProgram());
|
||||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/fxaa.fp", prolog, maxVersion);
|
shader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", maxVersion);
|
||||||
shader.Link("shaders/glsl/fxaa");
|
shader->Compile(IShaderProgram::Fragment, "shaders/glsl/fxaa.fp", prolog, maxVersion);
|
||||||
shader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
shader->Link("shaders/glsl/fxaa");
|
||||||
|
shader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
shader.Bind(q);
|
shader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,7 +27,7 @@
|
||||||
#ifndef __GL_FXAASHADER_H__
|
#ifndef __GL_FXAASHADER_H__
|
||||||
#define __GL_FXAASHADER_H__
|
#define __GL_FXAASHADER_H__
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
|
#include "hwrenderer/postprocessing/hw_postprocess_cvars.h"
|
||||||
|
|
||||||
class FFXAALumaShader
|
class FFXAALumaShader
|
||||||
|
@ -36,7 +36,7 @@ public:
|
||||||
void Bind(IRenderQueue *q);
|
void Bind(IRenderQueue *q);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -64,7 +64,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShaders[Count];
|
std::unique_ptr<IShaderProgram> mShaders[Count];
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // __GL_FXAASHADER_H__
|
#endif // __GL_FXAASHADER_H__
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "gl/shaders/gl_lensshader.h"
|
#include "gl/shaders/gl_lensshader.h"
|
||||||
|
|
||||||
|
@ -35,11 +34,12 @@ void FLensShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/lensdistortion");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/lensdistortion.fp", prolog, 330);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/lensdistortion");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_LENSSHADER_H
|
#ifndef __GL_LENSSHADER_H
|
||||||
#define __GL_LENSSHADER_H
|
#define __GL_LENSSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FLensShader
|
class FLensShader
|
||||||
{
|
{
|
||||||
|
@ -33,7 +33,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -111,7 +111,7 @@ bool PostProcessShaderInstance::IsShaderSupported()
|
||||||
|
|
||||||
void PostProcessShaderInstance::CompileShader()
|
void PostProcessShaderInstance::CompileShader()
|
||||||
{
|
{
|
||||||
if (mProgram)
|
if (mProgram.Handle())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the custom shader
|
// Get the custom shader
|
||||||
|
@ -164,10 +164,10 @@ void PostProcessShaderInstance::CompileShader()
|
||||||
prolog += uniformTextures;
|
prolog += uniformTextures;
|
||||||
prolog += pipelineInOut;
|
prolog += pipelineInOut;
|
||||||
|
|
||||||
mProgram.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", Desc->ShaderVersion);
|
mProgram.Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", Desc->ShaderVersion);
|
||||||
mProgram.Compile(FShaderProgram::Fragment, lumpName, code, prolog.GetChars(), Desc->ShaderVersion);
|
mProgram.Compile(IShaderProgram::Fragment, lumpName, code, prolog.GetChars(), Desc->ShaderVersion);
|
||||||
mProgram.Link(Desc->ShaderLumpName.GetChars());
|
mProgram.Link(Desc->ShaderLumpName.GetChars());
|
||||||
mInputTexture.Init(mProgram, "InputTexture");
|
mInputTexture.Init(mProgram.Handle(), "InputTexture");
|
||||||
}
|
}
|
||||||
|
|
||||||
void PostProcessShaderInstance::UpdateUniforms()
|
void PostProcessShaderInstance::UpdateUniforms()
|
||||||
|
@ -176,7 +176,7 @@ void PostProcessShaderInstance::UpdateUniforms()
|
||||||
TMap<FString, PostProcessUniformValue>::Pair *pair;
|
TMap<FString, PostProcessUniformValue>::Pair *pair;
|
||||||
while (it.NextPair(pair))
|
while (it.NextPair(pair))
|
||||||
{
|
{
|
||||||
int location = glGetUniformLocation(mProgram, pair->Key.GetChars());
|
int location = glGetUniformLocation(mProgram.Handle(), pair->Key.GetChars());
|
||||||
if (location != -1)
|
if (location != -1)
|
||||||
{
|
{
|
||||||
switch (pair->Value.Type)
|
switch (pair->Value.Type)
|
||||||
|
@ -207,7 +207,7 @@ void PostProcessShaderInstance::BindTextures()
|
||||||
TMap<FString, FString>::Pair *pair;
|
TMap<FString, FString>::Pair *pair;
|
||||||
while (it.NextPair(pair))
|
while (it.NextPair(pair))
|
||||||
{
|
{
|
||||||
int location = glGetUniformLocation(mProgram, pair->Key.GetChars());
|
int location = glGetUniformLocation(mProgram.Handle(), pair->Key.GetChars());
|
||||||
if (location == -1)
|
if (location == -1)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
|
|
@ -36,7 +36,7 @@ void FPresent3DCheckerShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
Init("shaders/glsl/present_checker3d.fp", "shaders/glsl/presentChecker3d");
|
Init("shaders/glsl/present_checker3d.fp", "shaders/glsl/presentChecker3d");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPresent3DColumnShader::Bind(IRenderQueue *q)
|
void FPresent3DColumnShader::Bind(IRenderQueue *q)
|
||||||
|
@ -45,7 +45,7 @@ void FPresent3DColumnShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
Init("shaders/glsl/present_column3d.fp", "shaders/glsl/presentColumn3d");
|
Init("shaders/glsl/present_column3d.fp", "shaders/glsl/presentColumn3d");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FPresent3DRowShader::Bind(IRenderQueue *q)
|
void FPresent3DRowShader::Bind(IRenderQueue *q)
|
||||||
|
@ -54,5 +54,5 @@ void FPresent3DRowShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
Init("shaders/glsl/present_row3d.fp", "shaders/glsl/presentRow3d");
|
Init("shaders/glsl/present_row3d.fp", "shaders/glsl/presentRow3d");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,6 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "gl/shaders/gl_presentshader.h"
|
#include "gl/shaders/gl_presentshader.h"
|
||||||
|
|
||||||
|
@ -33,10 +32,11 @@ void FPresentShaderBase::Init(const char * vtx_shader_name, const char * program
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", prolog, 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, vtx_shader_name, prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquadscale.vp", prolog, 330);
|
||||||
mShader.Link(program_name);
|
mShader->Compile(IShaderProgram::Fragment, vtx_shader_name, prolog, 330);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link(program_name);
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,5 +46,5 @@ void FPresentShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
Init("shaders/glsl/present.fp", "shaders/glsl/present");
|
Init("shaders/glsl/present.fp", "shaders/glsl/present");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_PRESENTSHADER_H
|
#ifndef __GL_PRESENTSHADER_H
|
||||||
#define __GL_PRESENTSHADER_H
|
#define __GL_PRESENTSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FPresentShaderBase
|
class FPresentShaderBase
|
||||||
{
|
{
|
||||||
|
@ -38,7 +38,7 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void Init(const char * vtx_shader_name, const char * program_name);
|
virtual void Init(const char * vtx_shader_name, const char * program_name);
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FPresentShader : public FPresentShaderBase
|
class FPresentShader : public FPresentShaderBase
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include "doomerrors.h"
|
#include "doomerrors.h"
|
||||||
#include "cmdlib.h"
|
#include "cmdlib.h"
|
||||||
#include "hwrenderer/utility/hw_shaderpatcher.h"
|
#include "hwrenderer/utility/hw_shaderpatcher.h"
|
||||||
|
#include "hwrenderer/data/shaderuniforms.h"
|
||||||
|
|
||||||
#include "gl_load/gl_interface.h"
|
#include "gl_load/gl_interface.h"
|
||||||
#include "gl/system/gl_debug.h"
|
#include "gl/system/gl_debug.h"
|
||||||
|
|
|
@ -382,11 +382,5 @@ public:
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
LIGHTBUF_BINDINGPOINT = 1,
|
|
||||||
POSTPROCESS_BINDINGPOINT = 2
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
|
@ -3,32 +3,23 @@
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
#include "gl_load/gl_system.h"
|
||||||
#include "gl_shader.h"
|
#include "gl_shader.h"
|
||||||
#include "hwrenderer/data/shaderuniforms.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class IRenderQueue;
|
class FShaderProgram : public IShaderProgram
|
||||||
|
|
||||||
class FShaderProgram
|
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
FShaderProgram();
|
FShaderProgram();
|
||||||
~FShaderProgram();
|
~FShaderProgram();
|
||||||
|
|
||||||
enum ShaderType
|
void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion) override;
|
||||||
{
|
void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion) override;
|
||||||
Vertex,
|
|
||||||
Fragment,
|
|
||||||
NumShaderTypes
|
|
||||||
};
|
|
||||||
|
|
||||||
void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion);
|
|
||||||
void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion);
|
|
||||||
void Link(const char *name);
|
void Link(const char *name);
|
||||||
void SetUniformBufferLocation(int index, const char *name);
|
void SetUniformBufferLocation(int index, const char *name);
|
||||||
|
|
||||||
void Bind(IRenderQueue *q); // the parameter here is just a preparation for Vulkan
|
void Bind(IRenderQueue *q) override; // the parameter here is just a preparation for Vulkan
|
||||||
|
|
||||||
operator GLuint() const { return mProgram; }
|
GLuint Handle() { return mProgram; }
|
||||||
explicit operator bool() const { return mProgram != 0; }
|
//explicit operator bool() const { return mProgram != 0; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram(const FShaderProgram &) = delete;
|
FShaderProgram(const FShaderProgram &) = delete;
|
||||||
|
|
|
@ -20,7 +20,6 @@
|
||||||
//--------------------------------------------------------------------------
|
//--------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "files.h"
|
#include "files.h"
|
||||||
#include "gl/shaders/gl_shadowmapshader.h"
|
#include "gl/shaders/gl_shadowmapshader.h"
|
||||||
|
|
||||||
|
@ -30,11 +29,12 @@ void FShadowMapShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 430);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/shadowmap.fp", prolog, 430);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 430);
|
||||||
mShader.Link("shaders/glsl/shadowmap");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/shadowmap.fp", prolog, 430);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/shadowmap");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_SHADOWMAPSHADER_H
|
#ifndef __GL_SHADOWMAPSHADER_H
|
||||||
#define __GL_SHADOWMAPSHADER_H
|
#define __GL_SHADOWMAPSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FShadowMapShader
|
class FShadowMapShader
|
||||||
{
|
{
|
||||||
|
@ -28,7 +28,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -25,7 +25,6 @@
|
||||||
**
|
**
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "gl_load/gl_system.h"
|
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
#include "hwrenderer/utility/hw_cvars.h"
|
#include "hwrenderer/utility/hw_cvars.h"
|
||||||
#include "gl/shaders/gl_tonemapshader.h"
|
#include "gl/shaders/gl_tonemapshader.h"
|
||||||
|
@ -37,11 +36,12 @@ void FTonemapShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
auto prolog = GetDefines(gl_tonemap);
|
auto prolog = GetDefines(gl_tonemap);
|
||||||
|
|
||||||
shader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
shader.reset(screen->CreateShaderProgram());
|
||||||
shader.Compile(FShaderProgram::Fragment, "shaders/glsl/tonemap.fp", prolog, 330);
|
shader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
shader.Link("shaders/glsl/tonemap");
|
shader->Compile(IShaderProgram::Fragment, "shaders/glsl/tonemap.fp", prolog, 330);
|
||||||
|
shader->Link("shaders/glsl/tonemap");
|
||||||
}
|
}
|
||||||
shader.Bind(q);
|
shader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool FTonemapShader::IsPaletteMode()
|
bool FTonemapShader::IsPaletteMode()
|
||||||
|
@ -68,24 +68,26 @@ void FExposureExtractShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureextract.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/exposureextract");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/exposureextract.fp", prolog, 330);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/exposureextract");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FExposureAverageShader::Bind(IRenderQueue *q)
|
void FExposureAverageShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
if (!mShader)
|
if (!mShader)
|
||||||
{
|
{
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 400);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 400);
|
||||||
mShader.Link("shaders/glsl/exposureaverage");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/exposureaverage.fp", "", 400);
|
||||||
|
mShader->Link("shaders/glsl/exposureaverage");
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
||||||
|
|
||||||
void FExposureCombineShader::Bind(IRenderQueue *q)
|
void FExposureCombineShader::Bind(IRenderQueue *q)
|
||||||
|
@ -94,11 +96,12 @@ void FExposureCombineShader::Bind(IRenderQueue *q)
|
||||||
{
|
{
|
||||||
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
FString prolog = Uniforms.CreateDeclaration("Uniforms", UniformBlock::Desc());
|
||||||
|
|
||||||
mShader.Compile(FShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
mShader.reset(screen->CreateShaderProgram());
|
||||||
mShader.Compile(FShaderProgram::Fragment, "shaders/glsl/exposurecombine.fp", prolog, 330);
|
mShader->Compile(IShaderProgram::Vertex, "shaders/glsl/screenquad.vp", "", 330);
|
||||||
mShader.Link("shaders/glsl/exposurecombine");
|
mShader->Compile(IShaderProgram::Fragment, "shaders/glsl/exposurecombine.fp", prolog, 330);
|
||||||
mShader.SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
mShader->Link("shaders/glsl/exposurecombine");
|
||||||
|
mShader->SetUniformBufferLocation(Uniforms.BindingPoint(), "Uniforms");
|
||||||
Uniforms.Init();
|
Uniforms.Init();
|
||||||
}
|
}
|
||||||
mShader.Bind(q);
|
mShader->Bind(q);
|
||||||
}
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
#ifndef __GL_TONEMAPSHADER_H
|
#ifndef __GL_TONEMAPSHADER_H
|
||||||
#define __GL_TONEMAPSHADER_H
|
#define __GL_TONEMAPSHADER_H
|
||||||
|
|
||||||
#include "gl_shaderprogram.h"
|
#include "hwrenderer/postprocessing/hw_shaderprogram.h"
|
||||||
|
|
||||||
class FTonemapShader
|
class FTonemapShader
|
||||||
{
|
{
|
||||||
|
@ -24,7 +24,7 @@ private:
|
||||||
|
|
||||||
static const char *GetDefines(int mode);
|
static const char *GetDefines(int mode);
|
||||||
|
|
||||||
FShaderProgram mShader[NumTonemapModes];
|
std::unique_ptr<IShaderProgram> mShader[NumTonemapModes];
|
||||||
};
|
};
|
||||||
|
|
||||||
class FExposureExtractShader
|
class FExposureExtractShader
|
||||||
|
@ -50,7 +50,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FExposureAverageShader
|
class FExposureAverageShader
|
||||||
|
@ -59,7 +59,7 @@ public:
|
||||||
void Bind(IRenderQueue *q);
|
void Bind(IRenderQueue *q);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
class FExposureCombineShader
|
class FExposureCombineShader
|
||||||
|
@ -89,7 +89,7 @@ public:
|
||||||
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
ShaderUniforms<UniformBlock, POSTPROCESS_BINDINGPOINT> Uniforms;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FShaderProgram mShader;
|
std::unique_ptr<IShaderProgram> mShader;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
|
@ -41,6 +41,7 @@
|
||||||
#include "gl/data/gl_uniformbuffer.h"
|
#include "gl/data/gl_uniformbuffer.h"
|
||||||
#include "gl/models/gl_models.h"
|
#include "gl/models/gl_models.h"
|
||||||
#include "gl/stereo3d/gl_stereo3d.h"
|
#include "gl/stereo3d/gl_stereo3d.h"
|
||||||
|
#include "gl/shaders/gl_shaderprogram.h"
|
||||||
#include "gl_debug.h"
|
#include "gl_debug.h"
|
||||||
#include "r_videoscale.h"
|
#include "r_videoscale.h"
|
||||||
|
|
||||||
|
@ -364,6 +365,12 @@ IUniformBuffer *OpenGLFrameBuffer::CreateUniformBuffer(size_t size, bool staticu
|
||||||
return new GLUniformBuffer(size, staticuse);
|
return new GLUniformBuffer(size, staticuse);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IShaderProgram *OpenGLFrameBuffer::CreateShaderProgram()
|
||||||
|
{
|
||||||
|
return new FShaderProgram;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void OpenGLFrameBuffer::UnbindTexUnit(int no)
|
void OpenGLFrameBuffer::UnbindTexUnit(int no)
|
||||||
{
|
{
|
||||||
FHardwareTexture::Unbind(no);
|
FHardwareTexture::Unbind(no);
|
||||||
|
|
|
@ -45,6 +45,7 @@ public:
|
||||||
void SetViewportRects(IntRect *bounds) override;
|
void SetViewportRects(IntRect *bounds) override;
|
||||||
void BlurScene(float amount) override;
|
void BlurScene(float amount) override;
|
||||||
IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) override;
|
IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) override;
|
||||||
|
IShaderProgram *CreateShaderProgram() override;
|
||||||
|
|
||||||
|
|
||||||
// Retrieves a buffer containing image data for a screenshot.
|
// Retrieves a buffer containing image data for a screenshot.
|
||||||
|
|
|
@ -19,15 +19,15 @@ typedef TFlags<ColormaskBits, uint8_t> Colormask;
|
||||||
|
|
||||||
class IRenderQueue
|
class IRenderQueue
|
||||||
{
|
{
|
||||||
Colormask mColorMask;
|
Colormask mColorMask;
|
||||||
|
|
||||||
|
|
||||||
Colormask GetColorMask() const
|
Colormask GetColorMask() const
|
||||||
{
|
{
|
||||||
return mColorMask;
|
return mColorMask;
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetColorMask(Colormask mask) = 0;
|
virtual void SetColorMask(Colormask mask) = 0;
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -4,6 +4,12 @@
|
||||||
#include "hwrenderer/data/uniformbuffer.h"
|
#include "hwrenderer/data/uniformbuffer.h"
|
||||||
#include "v_video.h"
|
#include "v_video.h"
|
||||||
|
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
LIGHTBUF_BINDINGPOINT = 1,
|
||||||
|
POSTPROCESS_BINDINGPOINT = 2
|
||||||
|
};
|
||||||
|
|
||||||
enum class UniformType
|
enum class UniformType
|
||||||
{
|
{
|
||||||
Int,
|
Int,
|
||||||
|
|
31
src/hwrenderer/postprocessing/hw_shaderprogram.h
Normal file
31
src/hwrenderer/postprocessing/hw_shaderprogram.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "hwrenderer/data/shaderuniforms.h"
|
||||||
|
|
||||||
|
class IRenderQueue;
|
||||||
|
|
||||||
|
class IShaderProgram
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
IShaderProgram() {}
|
||||||
|
virtual ~IShaderProgram() {}
|
||||||
|
|
||||||
|
enum ShaderType
|
||||||
|
{
|
||||||
|
Vertex,
|
||||||
|
Fragment,
|
||||||
|
NumShaderTypes
|
||||||
|
};
|
||||||
|
|
||||||
|
virtual void Compile(ShaderType type, const char *lumpName, const char *defines, int maxGlslVersion) = 0;
|
||||||
|
virtual void Compile(ShaderType type, const char *name, const FString &code, const char *defines, int maxGlslVersion) = 0;
|
||||||
|
virtual void Link(const char *name) = 0;
|
||||||
|
virtual void SetUniformBufferLocation(int index, const char *name) = 0;
|
||||||
|
|
||||||
|
virtual void Bind(IRenderQueue *q) = 0; // the parameter here is just a preparation for Vulkan
|
||||||
|
|
||||||
|
private:
|
||||||
|
IShaderProgram(const IShaderProgram &) = delete;
|
||||||
|
IShaderProgram &operator=(const IShaderProgram &) = delete;
|
||||||
|
};
|
|
@ -45,6 +45,7 @@
|
||||||
#include "v_2ddrawer.h"
|
#include "v_2ddrawer.h"
|
||||||
|
|
||||||
struct sector_t;
|
struct sector_t;
|
||||||
|
class IShaderProgram;
|
||||||
|
|
||||||
enum EHWCaps
|
enum EHWCaps
|
||||||
{
|
{
|
||||||
|
@ -418,6 +419,7 @@ public:
|
||||||
|
|
||||||
// Interface to hardware rendering resources
|
// Interface to hardware rendering resources
|
||||||
virtual IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) { return nullptr; }
|
virtual IUniformBuffer *CreateUniformBuffer(size_t size, bool staticuse = false) { return nullptr; }
|
||||||
|
virtual IShaderProgram *CreateShaderProgram() { return nullptr; }
|
||||||
|
|
||||||
// Begin 2D drawing operations.
|
// Begin 2D drawing operations.
|
||||||
// Returns true if hardware-accelerated 2D has been entered, false if not.
|
// Returns true if hardware-accelerated 2D has been entered, false if not.
|
||||||
|
|
Loading…
Reference in a new issue