Moves CShaderProgram to backend and handling via CDeviceCommandContext.
Differential Revision: https://code.wildfiregames.com/D4548 This was SVN commit r26652.
This commit is contained in:
parent
1b0891c566
commit
b4253d48cb
@ -39,7 +39,7 @@ using PlaneArray2D = std::array<float, 12>;
|
|||||||
|
|
||||||
inline void DrawTextureImpl(
|
inline void DrawTextureImpl(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, const CTexturePtr& texture,
|
Renderer::Backend::GL::CShaderProgram* shader, const CTexturePtr& texture,
|
||||||
const PlaneArray2D& vertices, PlaneArray2D uvs,
|
const PlaneArray2D& vertices, PlaneArray2D uvs,
|
||||||
const CColor& multiply, const CColor& add, const float grayscaleFactor)
|
const CColor& multiply, const CColor& add, const float grayscaleFactor)
|
||||||
{
|
{
|
||||||
@ -83,10 +83,10 @@ public:
|
|||||||
CShaderDefines defines;
|
CShaderDefines defines;
|
||||||
Tech = g_Renderer.GetShaderManager().LoadEffect(str_canvas2d, defines);
|
Tech = g_Renderer.GetShaderManager().LoadEffect(str_canvas2d, defines);
|
||||||
ENSURE(Tech);
|
ENSURE(Tech);
|
||||||
Tech->BeginPass();
|
|
||||||
DeviceCommandContext->SetGraphicsPipelineState(
|
DeviceCommandContext->SetGraphicsPipelineState(
|
||||||
Tech->GetGraphicsPipelineStateDesc());
|
Tech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& shader = Tech->GetShader();
|
DeviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = Tech->GetShader();
|
||||||
shader->Uniform(str_transform, GetDefaultGuiMatrix());
|
shader->Uniform(str_transform, GetDefaultGuiMatrix());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -95,7 +95,7 @@ public:
|
|||||||
if (!Tech)
|
if (!Tech)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Tech->EndPass();
|
DeviceCommandContext->EndPass();
|
||||||
Tech.reset();
|
Tech.reset();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +246,7 @@ void CCanvas2D::DrawLine(const std::vector<CVector2D>& points, const float width
|
|||||||
|
|
||||||
m->BindTechIfNeeded();
|
m->BindTechIfNeeded();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = m->Tech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = m->Tech->GetShader();
|
||||||
shader->BindTexture(str_tex, g_Renderer.GetTextureManager().GetAlphaGradientTexture()->GetBackendTexture());
|
shader->BindTexture(str_tex, g_Renderer.GetTextureManager().GetAlphaGradientTexture()->GetBackendTexture());
|
||||||
shader->Uniform(str_colorAdd, CColor(0.0f, 0.0f, 0.0f, 0.0f));
|
shader->Uniform(str_colorAdd, CColor(0.0f, 0.0f, 0.0f, 0.0f));
|
||||||
shader->Uniform(str_colorMul, color);
|
shader->Uniform(str_colorMul, color);
|
||||||
@ -324,7 +324,7 @@ void CCanvas2D::DrawText(CTextRenderer& textRenderer)
|
|||||||
{
|
{
|
||||||
m->BindTechIfNeeded();
|
m->BindTechIfNeeded();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = m->Tech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = m->Tech->GetShader();
|
||||||
shader->Uniform(str_grayscaleFactor, 0.0f);
|
shader->Uniform(str_grayscaleFactor, 0.0f);
|
||||||
|
|
||||||
textRenderer.Render(m->DeviceCommandContext, shader, GetDefaultGuiMatrix());
|
textRenderer.Render(m->DeviceCommandContext, shader, GetDefaultGuiMatrix());
|
||||||
|
@ -80,7 +80,7 @@ CLOSTexture::~CLOSTexture()
|
|||||||
bool CLOSTexture::CreateShader()
|
bool CLOSTexture::CreateShader()
|
||||||
{
|
{
|
||||||
m_SmoothTech = g_Renderer.GetShaderManager().LoadEffect(str_los_interp);
|
m_SmoothTech = g_Renderer.GetShaderManager().LoadEffect(str_los_interp);
|
||||||
CShaderProgramPtr shader = m_SmoothTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = m_SmoothTech->GetShader();
|
||||||
|
|
||||||
m_ShaderInitialized = m_SmoothTech && shader;
|
m_ShaderInitialized = m_SmoothTech && shader;
|
||||||
|
|
||||||
@ -141,11 +141,11 @@ void CLOSTexture::InterpolateLOS(Renderer::Backend::GL::CDeviceCommandContext* d
|
|||||||
GPU_SCOPED_LABEL(deviceCommandContext, "Render LOS texture");
|
GPU_SCOPED_LABEL(deviceCommandContext, "Render LOS texture");
|
||||||
deviceCommandContext->SetFramebuffer(m_SmoothFramebuffers[m_WhichTexture].get());
|
deviceCommandContext->SetFramebuffer(m_SmoothFramebuffers[m_WhichTexture].get());
|
||||||
|
|
||||||
m_SmoothTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
m_SmoothTech->GetGraphicsPipelineStateDesc());
|
m_SmoothTech->GetGraphicsPipelineStateDesc());
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = m_SmoothTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = m_SmoothTech->GetShader();
|
||||||
|
|
||||||
shader->BindTexture(str_losTex1, m_Texture.get());
|
shader->BindTexture(str_losTex1, m_Texture.get());
|
||||||
shader->BindTexture(str_losTex2, m_SmoothTextures[m_WhichTexture].get());
|
shader->BindTexture(str_losTex2, m_SmoothTextures[m_WhichTexture].get());
|
||||||
@ -188,7 +188,7 @@ void CLOSTexture::InterpolateLOS(Renderer::Backend::GL::CDeviceCommandContext* d
|
|||||||
|
|
||||||
g_Renderer.SetViewport(oldVp);
|
g_Renderer.SetViewport(oldVp);
|
||||||
|
|
||||||
m_SmoothTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
deviceCommandContext->SetFramebuffer(
|
deviceCommandContext->SetFramebuffer(
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
||||||
|
@ -72,7 +72,7 @@ unsigned int ScaleColor(unsigned int color, float x)
|
|||||||
|
|
||||||
void DrawTexture(
|
void DrawTexture(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader)
|
Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
const float quadUVs[] =
|
const float quadUVs[] =
|
||||||
{
|
{
|
||||||
@ -363,7 +363,7 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
const float invTileMapSize = 1.0f / static_cast<float>(TERRAIN_TILE_SIZE * m_MapSize);
|
const float invTileMapSize = 1.0f / static_cast<float>(TERRAIN_TILE_SIZE * m_MapSize);
|
||||||
const float texCoordMax = m_TerrainTexture ? static_cast<float>(m_MapSize - 1) / m_TerrainTexture->GetWidth() : 1.0f;
|
const float texCoordMax = m_TerrainTexture ? static_cast<float>(m_MapSize - 1) / m_TerrainTexture->GetWidth() : 1.0f;
|
||||||
|
|
||||||
CShaderProgramPtr shader;
|
Renderer::Backend::GL::CShaderProgram* shader;
|
||||||
CShaderTechniquePtr tech;
|
CShaderTechniquePtr tech;
|
||||||
|
|
||||||
CShaderDefines baseDefines;
|
CShaderDefines baseDefines;
|
||||||
@ -372,8 +372,8 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, baseDefines);
|
tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, baseDefines);
|
||||||
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
||||||
tech->GetGraphicsPipelineStateDesc();
|
tech->GetGraphicsPipelineStateDesc();
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
shader = tech->GetShader();
|
shader = tech->GetShader();
|
||||||
|
|
||||||
if (m_TerrainTexture)
|
if (m_TerrainTexture)
|
||||||
@ -392,6 +392,7 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
|
|
||||||
if (m_TerrainTexture)
|
if (m_TerrainTexture)
|
||||||
DrawTexture(deviceCommandContext, shader);
|
DrawTexture(deviceCommandContext, shader);
|
||||||
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
pipelineStateDesc.blendState.enabled = true;
|
pipelineStateDesc.blendState.enabled = true;
|
||||||
pipelineStateDesc.blendState.srcColorBlendFactor = pipelineStateDesc.blendState.srcAlphaBlendFactor =
|
pipelineStateDesc.blendState.srcColorBlendFactor = pipelineStateDesc.blendState.srcAlphaBlendFactor =
|
||||||
@ -405,6 +406,7 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
Renderer::Backend::ColorWriteMask::GREEN |
|
Renderer::Backend::ColorWriteMask::GREEN |
|
||||||
Renderer::Backend::ColorWriteMask::BLUE;
|
Renderer::Backend::ColorWriteMask::BLUE;
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
// Draw territory boundaries
|
// Draw territory boundaries
|
||||||
CTerritoryTexture& territoryTexture = g_Game->GetView()->GetTerritoryTexture();
|
CTerritoryTexture& territoryTexture = g_Game->GetView()->GetTerritoryTexture();
|
||||||
@ -414,11 +416,13 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
shader->Uniform(str_textureTransform, territoryTexture.GetMinimapTextureMatrix());
|
shader->Uniform(str_textureTransform, territoryTexture.GetMinimapTextureMatrix());
|
||||||
|
|
||||||
DrawTexture(deviceCommandContext, shader);
|
DrawTexture(deviceCommandContext, shader);
|
||||||
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
pipelineStateDesc.blendState.enabled = false;
|
pipelineStateDesc.blendState.enabled = false;
|
||||||
pipelineStateDesc.blendState.colorWriteMask =
|
pipelineStateDesc.blendState.colorWriteMask =
|
||||||
Renderer::Backend::ColorWriteMask::ALPHA;
|
Renderer::Backend::ColorWriteMask::ALPHA;
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
shader->BindTexture(str_baseTex, losTexture.GetTexture());
|
shader->BindTexture(str_baseTex, losTexture.GetTexture());
|
||||||
shader->Uniform(str_transform, baseTransform);
|
shader->Uniform(str_transform, baseTransform);
|
||||||
@ -426,14 +430,14 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
|
|
||||||
DrawTexture(deviceCommandContext, shader);
|
DrawTexture(deviceCommandContext, shader);
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
CShaderDefines pointDefines;
|
CShaderDefines pointDefines;
|
||||||
pointDefines.Add(str_MINIMAP_POINT, str_1);
|
pointDefines.Add(str_MINIMAP_POINT, str_1);
|
||||||
tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, pointDefines);
|
tech = g_Renderer.GetShaderManager().LoadEffect(str_minimap, pointDefines);
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
tech->GetGraphicsPipelineStateDesc());
|
tech->GetGraphicsPipelineStateDesc());
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
shader = tech->GetShader();
|
shader = tech->GetShader();
|
||||||
shader->Uniform(str_transform, baseTransform);
|
shader->Uniform(str_transform, baseTransform);
|
||||||
|
|
||||||
@ -581,7 +585,7 @@ void CMiniMapTexture::RenderFinalTexture(
|
|||||||
deviceCommandContext->SetScissors(0, nullptr);
|
deviceCommandContext->SetScissors(0, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
deviceCommandContext->SetFramebuffer(
|
deviceCommandContext->SetFramebuffer(
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
||||||
g_Renderer.SetViewport(oldViewPort);
|
g_Renderer.SetViewport(oldViewPort);
|
||||||
|
@ -176,7 +176,7 @@ void CParticleEmitter::PrepareForRendering()
|
|||||||
|
|
||||||
void CParticleEmitter::Bind(
|
void CParticleEmitter::Bind(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader)
|
Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
m_Type->m_Texture->UploadBackendTextureIfNeeded(deviceCommandContext);
|
m_Type->m_Texture->UploadBackendTextureIfNeeded(deviceCommandContext);
|
||||||
|
|
||||||
@ -194,7 +194,7 @@ void CParticleEmitter::Bind(
|
|||||||
|
|
||||||
void CParticleEmitter::RenderArray(
|
void CParticleEmitter::RenderArray(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader)
|
Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
if (m_Particles.empty())
|
if (m_Particles.empty())
|
||||||
return;
|
return;
|
||||||
|
@ -22,6 +22,7 @@
|
|||||||
#include "graphics/ParticleEmitterType.h"
|
#include "graphics/ParticleEmitterType.h"
|
||||||
#include "maths/Quaternion.h"
|
#include "maths/Quaternion.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
#include "renderer/VertexArray.h"
|
#include "renderer/VertexArray.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
@ -123,14 +124,14 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Bind(
|
void Bind(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader);
|
Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Draw the vertex array.
|
* Draw the vertex array.
|
||||||
*/
|
*/
|
||||||
void RenderArray(
|
void RenderArray(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader);
|
Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Stop this emitter emitting new particles, and pass responsibility for rendering
|
* Stop this emitter emitting new particles, and pass responsibility for rendering
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2021 Wildfire Games.
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -225,7 +225,7 @@ CVector4D CShaderUniforms::GetVector(const char* name) const
|
|||||||
return CVector4D();
|
return CVector4D();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShaderUniforms::BindUniforms(const CShaderProgramPtr& shader) const
|
void CShaderUniforms::BindUniforms(Renderer::Backend::GL::CShaderProgram* shader) const
|
||||||
{
|
{
|
||||||
const std::vector<SItems::Item>& items = m_Items->items;
|
const std::vector<SItems::Item>& items = m_Items->items;
|
||||||
for (size_t i = 0; i < items.size(); ++i)
|
for (size_t i = 0; i < items.size(); ++i)
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2021 Wildfire Games.
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -18,9 +18,9 @@
|
|||||||
#ifndef INCLUDED_SHADERDEFINES
|
#ifndef INCLUDED_SHADERDEFINES
|
||||||
#define INCLUDED_SHADERDEFINES
|
#define INCLUDED_SHADERDEFINES
|
||||||
|
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
|
||||||
#include "ps/CStr.h"
|
#include "ps/CStr.h"
|
||||||
#include "ps/CStrIntern.h"
|
#include "ps/CStrIntern.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <unordered_map>
|
#include <unordered_map>
|
||||||
@ -178,7 +178,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Bind the collection of uniforms onto the given shader.
|
* Bind the collection of uniforms onto the given shader.
|
||||||
*/
|
*/
|
||||||
void BindUniforms(const CShaderProgramPtr& shader) const;
|
void BindUniforms(Renderer::Backend::GL::CShaderProgram* shader) const;
|
||||||
};
|
};
|
||||||
|
|
||||||
// Add here the types of queries we can make in the renderer
|
// Add here the types of queries we can make in the renderer
|
||||||
|
@ -66,7 +66,7 @@ CShaderManager::~CShaderManager()
|
|||||||
UnregisterFileReloadFunc(ReloadChangedFileCB, this);
|
UnregisterFileReloadFunc(ReloadChangedFileCB, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
CShaderProgramPtr CShaderManager::LoadProgram(const char* name, const CShaderDefines& defines)
|
CShaderProgramPtr CShaderManager::LoadProgram(const CStr& name, const CShaderDefines& defines)
|
||||||
{
|
{
|
||||||
CacheKey key = { name, defines };
|
CacheKey key = { name, defines };
|
||||||
std::map<CacheKey, CShaderProgramPtr>::iterator it = m_ProgramCache.find(key);
|
std::map<CacheKey, CShaderProgramPtr>::iterator it = m_ProgramCache.find(key);
|
||||||
@ -129,10 +129,10 @@ CShaderTechniquePtr CShaderManager::LoadEffect(CStrIntern name, const CShaderDef
|
|||||||
return tech;
|
return tech;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CShaderManager::NewEffect(const char* name, const CShaderDefines& baseDefines, CShaderTechniquePtr& tech)
|
bool CShaderManager::NewEffect(const CStr& name, const CShaderDefines& baseDefines, CShaderTechniquePtr& tech)
|
||||||
{
|
{
|
||||||
PROFILE2("loading effect");
|
PROFILE2("loading effect");
|
||||||
PROFILE2_ATTR("name: %s", name);
|
PROFILE2_ATTR("name: %s", name.c_str());
|
||||||
|
|
||||||
VfsPath xmlFilename = L"shaders/effects/" + wstring_from_utf8(name) + L".xml";
|
VfsPath xmlFilename = L"shaders/effects/" + wstring_from_utf8(name) + L".xml";
|
||||||
|
|
||||||
@ -256,7 +256,6 @@ bool CShaderManager::NewEffect(const char* name, const CShaderDefines& baseDefin
|
|||||||
{
|
{
|
||||||
CShaderDefines passDefines = techDefines;
|
CShaderDefines passDefines = techDefines;
|
||||||
|
|
||||||
CShaderPass pass;
|
|
||||||
Renderer::Backend::GraphicsPipelineStateDesc passPipelineStateDesc =
|
Renderer::Backend::GraphicsPipelineStateDesc passPipelineStateDesc =
|
||||||
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc();
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc();
|
||||||
|
|
||||||
@ -393,12 +392,10 @@ bool CShaderManager::NewEffect(const char* name, const CShaderDefines& baseDefin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pass.SetPipelineStateDesc(passPipelineStateDesc);
|
techPasses.emplace_back(
|
||||||
|
passPipelineStateDesc,
|
||||||
// Load the shader program after we've read all the possibly-relevant <define>s
|
// Load the shader program after we've read all the possibly-relevant <define>s.
|
||||||
pass.SetShader(LoadProgram(Child.GetAttributes().GetNamedItem(at_shader).c_str(), passDefines));
|
LoadProgram(Child.GetAttributes().GetNamedItem(at_shader).c_str(), passDefines));
|
||||||
|
|
||||||
techPasses.emplace_back(std::move(pass));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2021 Wildfire Games.
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -110,9 +110,9 @@ private:
|
|||||||
* @param defines key/value set of preprocessor definitions
|
* @param defines key/value set of preprocessor definitions
|
||||||
* @return loaded program, or null pointer on error
|
* @return loaded program, or null pointer on error
|
||||||
*/
|
*/
|
||||||
CShaderProgramPtr LoadProgram(const char* name, const CShaderDefines& defines);
|
CShaderProgramPtr LoadProgram(const CStr& name, const CShaderDefines& defines);
|
||||||
|
|
||||||
bool NewEffect(const char* name, const CShaderDefines& defines, CShaderTechniquePtr& tech);
|
bool NewEffect(const CStr& name, const CShaderDefines& defines, CShaderTechniquePtr& tech);
|
||||||
|
|
||||||
static Status ReloadChangedFileCB(void* param, const VfsPath& path);
|
static Status ReloadChangedFileCB(void* param, const VfsPath& path);
|
||||||
Status ReloadChangedFile(const VfsPath& path);
|
Status ReloadChangedFile(const VfsPath& path);
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -18,181 +18,38 @@
|
|||||||
#ifndef INCLUDED_SHADERPROGRAM
|
#ifndef INCLUDED_SHADERPROGRAM
|
||||||
#define INCLUDED_SHADERPROGRAM
|
#define INCLUDED_SHADERPROGRAM
|
||||||
|
|
||||||
|
#include "graphics/ShaderDefines.h"
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgramPtr.h"
|
||||||
#include "lib/ogl.h"
|
|
||||||
#include "lib/file/vfs/vfs_path.h"
|
#include "lib/file/vfs/vfs_path.h"
|
||||||
#include "renderer/backend/Format.h"
|
#include "ps/CStr.h"
|
||||||
#include "renderer/backend/gl/Texture.h"
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
|
#include "renderer/backend/IShaderProgram.h"
|
||||||
|
|
||||||
#include <map>
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
|
|
||||||
struct CColor;
|
|
||||||
class CMatrix3D;
|
|
||||||
class CVector3D;
|
|
||||||
class CShaderDefines;
|
|
||||||
class CStrIntern;
|
|
||||||
|
|
||||||
// Vertex data stream flags
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
STREAM_POS = (1 << 0),
|
|
||||||
STREAM_NORMAL = (1 << 1),
|
|
||||||
STREAM_COLOR = (1 << 2),
|
|
||||||
STREAM_UV0 = (1 << 3),
|
|
||||||
STREAM_UV1 = (1 << 4),
|
|
||||||
STREAM_UV2 = (1 << 5),
|
|
||||||
STREAM_UV3 = (1 << 6)
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A compiled vertex+fragment shader program.
|
* A wrapper for backend shader program to handle high-level operations like
|
||||||
* The implementation may use GL_ARB_{vertex,fragment}_program (ARB assembly syntax)
|
* file reloading and handling errors on reload.
|
||||||
* or GL_ARB_{vertex,fragment}_shader (GLSL), or may use hard-coded fixed-function
|
|
||||||
* multitexturing setup code; the difference is hidden from the caller.
|
|
||||||
*
|
|
||||||
* Texture/uniform IDs are typically strings, corresponding to the names defined in
|
|
||||||
* the shader .xml file. Alternatively (and more efficiently, if used very frequently),
|
|
||||||
* call GetTextureBinding/GetUniformBinding and pass its return value as the ID.
|
|
||||||
* Setting uniforms that the shader .xml doesn't support is harmless.
|
|
||||||
*
|
|
||||||
* For a high-level overview of shaders and materials, see
|
|
||||||
* http://trac.wildfiregames.com/wiki/MaterialSystem
|
|
||||||
*/
|
*/
|
||||||
class CShaderProgram
|
class CShaderProgram
|
||||||
{
|
{
|
||||||
NONCOPYABLE(CShaderProgram);
|
NONCOPYABLE(CShaderProgram);
|
||||||
|
|
||||||
public:
|
public:
|
||||||
typedef CStrIntern attrib_id_t;
|
static CShaderProgramPtr Create(const CStr& name, const CShaderDefines& defines);
|
||||||
typedef CStrIntern texture_id_t;
|
|
||||||
typedef CStrIntern uniform_id_t;
|
|
||||||
typedef std::pair<int, GLenum> frag_index_pair_t;
|
|
||||||
|
|
||||||
static CShaderProgramPtr Create(const char* name, const CShaderDefines& baseDefines);
|
void Reload();
|
||||||
|
|
||||||
/**
|
std::vector<VfsPath> GetFileDependencies() const;
|
||||||
* Represents a uniform attribute or texture binding.
|
|
||||||
* For uniforms:
|
|
||||||
* - ARB shaders store vertex location in 'first', fragment location in 'second'.
|
|
||||||
* - GLSL shaders store uniform location in 'first', data type in 'second'.
|
|
||||||
* For textures, all store texture target (e.g. GL_TEXTURE_2D) in 'first', texture unit in 'second'.
|
|
||||||
* Non-existent bindings must store -1 in both.
|
|
||||||
*/
|
|
||||||
struct Binding
|
|
||||||
{
|
|
||||||
Binding(int a, int b) : first(a), second(b) { }
|
|
||||||
|
|
||||||
Binding() : first(-1), second(-1) { }
|
Renderer::Backend::GL::CShaderProgram* GetBackendShaderProgram() { return m_BackendShaderProgram.get(); }
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether this uniform attribute is active in the shader.
|
|
||||||
* If not then there's no point calling Uniform() to set its value.
|
|
||||||
*/
|
|
||||||
bool Active() const { return first != -1 || second != -1; }
|
|
||||||
|
|
||||||
int first;
|
|
||||||
int second;
|
|
||||||
};
|
|
||||||
|
|
||||||
virtual ~CShaderProgram() { }
|
|
||||||
|
|
||||||
virtual void Reload() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Binds the shader into the GL context. Call this before calling Uniform()
|
|
||||||
* or trying to render with it.
|
|
||||||
*/
|
|
||||||
virtual void Bind() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Unbinds the shader from the GL context. Call this after rendering with it.
|
|
||||||
*/
|
|
||||||
virtual void Unbind() = 0;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns bitset of STREAM_* value, indicating what vertex data streams the
|
|
||||||
* vertex shader needs (e.g. position, color, UV, ...).
|
|
||||||
*/
|
|
||||||
int GetStreamFlags() const;
|
|
||||||
|
|
||||||
|
|
||||||
virtual Binding GetTextureBinding(texture_id_t id) = 0;
|
|
||||||
|
|
||||||
// Variants of texture binding:
|
|
||||||
void BindTexture(texture_id_t id, const Renderer::Backend::GL::CTexture* tex);
|
|
||||||
void BindTexture(Binding id, const Renderer::Backend::GL::CTexture* tex);
|
|
||||||
|
|
||||||
virtual Binding GetUniformBinding(uniform_id_t id) = 0;
|
|
||||||
|
|
||||||
// Uniform-setting methods that subclasses must define:
|
|
||||||
virtual void Uniform(Binding id, float v0, float v1, float v2, float v3) = 0;
|
|
||||||
virtual void Uniform(Binding id, const CMatrix3D& v) = 0;
|
|
||||||
virtual void Uniform(Binding id, size_t count, const CMatrix3D* v) = 0;
|
|
||||||
virtual void Uniform(Binding id, size_t count, const float* v) = 0;
|
|
||||||
|
|
||||||
// Convenient uniform-setting wrappers:
|
|
||||||
|
|
||||||
void Uniform(Binding id, int v);
|
|
||||||
void Uniform(Binding id, float v);
|
|
||||||
void Uniform(Binding id, float v0, float v1);
|
|
||||||
void Uniform(Binding id, const CVector3D& v);
|
|
||||||
void Uniform(Binding id, const CColor& v);
|
|
||||||
|
|
||||||
void Uniform(uniform_id_t id, int v);
|
|
||||||
void Uniform(uniform_id_t id, float v);
|
|
||||||
void Uniform(uniform_id_t id, float v0, float v1);
|
|
||||||
void Uniform(uniform_id_t id, const CVector3D& v);
|
|
||||||
void Uniform(uniform_id_t id, const CColor& v);
|
|
||||||
void Uniform(uniform_id_t id, float v0, float v1, float v2, float v3);
|
|
||||||
void Uniform(uniform_id_t id, const CMatrix3D& v);
|
|
||||||
void Uniform(uniform_id_t id, size_t count, const CMatrix3D* v);
|
|
||||||
void Uniform(uniform_id_t id, size_t count, const float* v);
|
|
||||||
|
|
||||||
// Vertex attribute pointers (equivalent to glVertexPointer etc):
|
|
||||||
|
|
||||||
virtual void VertexPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
|
||||||
virtual void NormalPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
|
||||||
virtual void ColorPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
|
||||||
virtual void TexCoordPointer(GLenum texture, const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
|
||||||
virtual void VertexAttribPointer(attrib_id_t id, const Renderer::Backend::Format format, GLboolean normalized, GLsizei stride, const void* pointer);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks that all the required vertex attributes have been set.
|
|
||||||
* Call this before calling Draw/DrawIndexed etc to avoid potential crashes.
|
|
||||||
*/
|
|
||||||
void AssertPointersBound();
|
|
||||||
|
|
||||||
virtual std::vector<VfsPath> GetFileDependencies() const = 0;
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
CShaderProgram(int streamflags);
|
CShaderProgram(const CStr& name, const CShaderDefines& defines);
|
||||||
|
|
||||||
/**
|
CStr m_Name;
|
||||||
* Construct based on ARB vertex/fragment program files.
|
CShaderDefines m_Defines;
|
||||||
*/
|
std::unique_ptr<Renderer::Backend::GL::CShaderProgram> m_BackendShaderProgram;
|
||||||
static CShaderProgramPtr ConstructARB(const VfsPath& vertexFile, const VfsPath& fragmentFile,
|
|
||||||
const CShaderDefines& defines,
|
|
||||||
const std::map<CStrIntern, int>& vertexIndexes, const std::map<CStrIntern, frag_index_pair_t>& fragmentIndexes,
|
|
||||||
int streamflags);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Construct based on GLSL vertex/fragment shader files.
|
|
||||||
*/
|
|
||||||
static CShaderProgramPtr ConstructGLSL(const VfsPath& vertexFile, const VfsPath& fragmentFile,
|
|
||||||
const CShaderDefines& defines,
|
|
||||||
const std::map<CStrIntern, int>& vertexAttribs,
|
|
||||||
int streamflags);
|
|
||||||
|
|
||||||
virtual void BindTexture(texture_id_t id, GLuint tex) = 0;
|
|
||||||
virtual void BindTexture(Binding id, GLuint tex) = 0;
|
|
||||||
|
|
||||||
int m_StreamFlags;
|
|
||||||
|
|
||||||
// Non-GLSL client state handling:
|
|
||||||
void BindClientStates();
|
|
||||||
void UnbindClientStates();
|
|
||||||
int m_ValidStreams; // which streams have been specified via VertexPointer etc since the last Bind
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_SHADERPROGRAM
|
#endif // INCLUDED_SHADERPROGRAM
|
||||||
|
@ -21,22 +21,12 @@
|
|||||||
|
|
||||||
#include "graphics/ShaderProgram.h"
|
#include "graphics/ShaderProgram.h"
|
||||||
|
|
||||||
CShaderPass::CShaderPass() = default;
|
CShaderPass::CShaderPass(
|
||||||
|
const Renderer::Backend::GraphicsPipelineStateDesc& pipelineStateDesc,
|
||||||
void CShaderPass::Bind()
|
const CShaderProgramPtr& shader)
|
||||||
|
: m_PipelineStateDesc(pipelineStateDesc), m_Shader(shader)
|
||||||
{
|
{
|
||||||
m_Shader->Bind();
|
m_PipelineStateDesc.shaderProgram = m_Shader->GetBackendShaderProgram();
|
||||||
}
|
|
||||||
|
|
||||||
void CShaderPass::Unbind()
|
|
||||||
{
|
|
||||||
m_Shader->Unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CShaderPass::SetPipelineStateDesc(
|
|
||||||
const Renderer::Backend::GraphicsPipelineStateDesc& pipelineStateDesc)
|
|
||||||
{
|
|
||||||
m_PipelineStateDesc = pipelineStateDesc;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
CShaderTechnique::CShaderTechnique() = default;
|
CShaderTechnique::CShaderTechnique() = default;
|
||||||
@ -51,19 +41,7 @@ int CShaderTechnique::GetNumPasses() const
|
|||||||
return m_Passes.size();
|
return m_Passes.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CShaderTechnique::BeginPass(int pass)
|
Renderer::Backend::GL::CShaderProgram* CShaderTechnique::GetShader(int pass) const
|
||||||
{
|
|
||||||
ENSURE(0 <= pass && pass < (int)m_Passes.size());
|
|
||||||
m_Passes[pass].Bind();
|
|
||||||
}
|
|
||||||
|
|
||||||
void CShaderTechnique::EndPass(int pass)
|
|
||||||
{
|
|
||||||
ENSURE(0 <= pass && pass < (int)m_Passes.size());
|
|
||||||
m_Passes[pass].Unbind();
|
|
||||||
}
|
|
||||||
|
|
||||||
const CShaderProgramPtr& CShaderTechnique::GetShader(int pass) const
|
|
||||||
{
|
{
|
||||||
ENSURE(0 <= pass && pass < (int)m_Passes.size());
|
ENSURE(0 <= pass && pass < (int)m_Passes.size());
|
||||||
return m_Passes[pass].GetShader();
|
return m_Passes[pass].GetShader();
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
#ifndef INCLUDED_SHADERTECHNIQUE
|
#ifndef INCLUDED_SHADERTECHNIQUE
|
||||||
#define INCLUDED_SHADERTECHNIQUE
|
#define INCLUDED_SHADERTECHNIQUE
|
||||||
|
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgram.h"
|
||||||
#include "graphics/ShaderTechniquePtr.h"
|
#include "graphics/ShaderTechniquePtr.h"
|
||||||
#include "lib/ogl.h"
|
|
||||||
#include "renderer/backend/PipelineState.h"
|
#include "renderer/backend/PipelineState.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -32,27 +31,9 @@
|
|||||||
class CShaderPass
|
class CShaderPass
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
CShaderPass();
|
CShaderPass(const Renderer::Backend::GraphicsPipelineStateDesc& pipelineStateDesc, const CShaderProgramPtr& shader);
|
||||||
|
|
||||||
/**
|
Renderer::Backend::GL::CShaderProgram* GetShader() const { return m_Shader->GetBackendShaderProgram(); }
|
||||||
* Set the shader program used for rendering with this pass.
|
|
||||||
*/
|
|
||||||
void SetShader(const CShaderProgramPtr& shader) { m_Shader = shader; }
|
|
||||||
|
|
||||||
void SetPipelineStateDesc(
|
|
||||||
const Renderer::Backend::GraphicsPipelineStateDesc& pipelineStateDesc);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set up all the GL state that was previously specified on this pass.
|
|
||||||
*/
|
|
||||||
void Bind();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reset the GL state to the default.
|
|
||||||
*/
|
|
||||||
void Unbind();
|
|
||||||
|
|
||||||
const CShaderProgramPtr& GetShader() const { return m_Shader; }
|
|
||||||
|
|
||||||
const Renderer::Backend::GraphicsPipelineStateDesc&
|
const Renderer::Backend::GraphicsPipelineStateDesc&
|
||||||
GetPipelineStateDesc() const { return m_PipelineStateDesc; }
|
GetPipelineStateDesc() const { return m_PipelineStateDesc; }
|
||||||
@ -75,9 +56,7 @@ public:
|
|||||||
|
|
||||||
int GetNumPasses() const;
|
int GetNumPasses() const;
|
||||||
|
|
||||||
void BeginPass(int pass = 0);
|
Renderer::Backend::GL::CShaderProgram* GetShader(int pass = 0) const;
|
||||||
void EndPass(int pass = 0);
|
|
||||||
const CShaderProgramPtr& GetShader(int pass = 0) const;
|
|
||||||
|
|
||||||
const Renderer::Backend::GraphicsPipelineStateDesc&
|
const Renderer::Backend::GraphicsPipelineStateDesc&
|
||||||
GetGraphicsPipelineStateDesc(int pass = 0) const;
|
GetGraphicsPipelineStateDesc(int pass = 0) const;
|
||||||
|
@ -204,7 +204,7 @@ struct SBatchCompare
|
|||||||
|
|
||||||
void CTextRenderer::Render(
|
void CTextRenderer::Render(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, const CMatrix3D& transform)
|
Renderer::Backend::GL::CShaderProgram* shader, const CMatrix3D& transform)
|
||||||
{
|
{
|
||||||
std::vector<u16> indexes;
|
std::vector<u16> indexes;
|
||||||
std::vector<t2f_v2i> vertexes;
|
std::vector<t2f_v2i> vertexes;
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
#define INCLUDED_TEXTRENDERER
|
#define INCLUDED_TEXTRENDERER
|
||||||
|
|
||||||
#include "graphics/Color.h"
|
#include "graphics/Color.h"
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgram.h"
|
||||||
#include "maths/Rect.h"
|
#include "maths/Rect.h"
|
||||||
#include "maths/Vector2D.h"
|
#include "maths/Vector2D.h"
|
||||||
#include "ps/CStrIntern.h"
|
#include "ps/CStrIntern.h"
|
||||||
@ -105,7 +105,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
void Render(
|
void Render(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, const CMatrix3D& transform);
|
Renderer::Backend::GL::CShaderProgram* shader, const CMatrix3D& transform);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct SBatchCompare;
|
friend struct SBatchCompare;
|
||||||
|
@ -97,7 +97,7 @@ void CropPointsByCircle(const std::array<CVector3D, 4>& points, const CVector3D&
|
|||||||
|
|
||||||
void DrawTexture(
|
void DrawTexture(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, float angle, float x, float y, float x2, float y2, float mapScale)
|
Renderer::Backend::GL::CShaderProgram* shader, float angle, float x, float y, float x2, float y2, float mapScale)
|
||||||
{
|
{
|
||||||
// Rotate the texture coordinates (0,0)-(coordMax,coordMax) around their center point (m,m)
|
// Rotate the texture coordinates (0,0)-(coordMax,coordMax) around their center point (m,m)
|
||||||
// Scale square maps to fit in circular minimap area
|
// Scale square maps to fit in circular minimap area
|
||||||
@ -409,7 +409,7 @@ void CMiniMap::Draw(CCanvas2D& canvas)
|
|||||||
CMiniMapTexture& miniMapTexture = g_Game->GetView()->GetMiniMapTexture();
|
CMiniMapTexture& miniMapTexture = g_Game->GetView()->GetMiniMapTexture();
|
||||||
if (miniMapTexture.GetTexture())
|
if (miniMapTexture.GetTexture())
|
||||||
{
|
{
|
||||||
CShaderProgramPtr shader;
|
Renderer::Backend::GL::CShaderProgram* shader;
|
||||||
CShaderTechniquePtr tech;
|
CShaderTechniquePtr tech;
|
||||||
|
|
||||||
CShaderDefines baseDefines;
|
CShaderDefines baseDefines;
|
||||||
@ -425,10 +425,10 @@ void CMiniMap::Draw(CCanvas2D& canvas)
|
|||||||
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
||||||
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
tech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
shader = tech->GetShader();
|
shader = tech->GetShader();
|
||||||
|
|
||||||
shader->BindTexture(str_baseTex, miniMapTexture.GetTexture());
|
shader->BindTexture(str_baseTex, miniMapTexture.GetTexture());
|
||||||
@ -443,7 +443,7 @@ void CMiniMap::Draw(CCanvas2D& canvas)
|
|||||||
const float angle = GetAngle();
|
const float angle = GetAngle();
|
||||||
DrawTexture(deviceCommandContext, shader, angle, x, y, x2, y2, m_MapScale);
|
DrawTexture(deviceCommandContext, shader, angle, x, y, x2, y2, m_MapScale);
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const CMiniMapTexture::Icon& icon : miniMapTexture.GetIcons())
|
for (const CMiniMapTexture::Icon& icon : miniMapTexture.GetIcons())
|
||||||
|
@ -85,15 +85,15 @@ void CDebugRenderer::DrawLine(
|
|||||||
#else
|
#else
|
||||||
CShaderTechniquePtr debugLineTech =
|
CShaderTechniquePtr debugLineTech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
||||||
debugLineTech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
SetGraphicsPipelineStateFromTechAndColor(
|
SetGraphicsPipelineStateFromTechAndColor(
|
||||||
deviceCommandContext, debugLineTech, color, depthTestEnabled);
|
deviceCommandContext, debugLineTech, color, depthTestEnabled);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CCamera& viewCamera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
const CCamera& viewCamera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
||||||
|
|
||||||
CShaderProgramPtr debugLineShader = debugLineTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* debugLineShader = debugLineTech->GetShader();
|
||||||
debugLineShader->Uniform(str_transform, viewCamera.GetViewProjection());
|
debugLineShader->Uniform(str_transform, viewCamera.GetViewProjection());
|
||||||
debugLineShader->Uniform(str_color, color);
|
debugLineShader->Uniform(str_color, color);
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ void CDebugRenderer::DrawLine(
|
|||||||
debugLineShader->AssertPointersBound();
|
debugLineShader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||||
|
|
||||||
debugLineTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -143,15 +143,15 @@ void CDebugRenderer::DrawCircle(const CVector3D& origin, const float radius, con
|
|||||||
#else
|
#else
|
||||||
CShaderTechniquePtr debugCircleTech =
|
CShaderTechniquePtr debugCircleTech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
||||||
debugCircleTech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
SetGraphicsPipelineStateFromTechAndColor(
|
SetGraphicsPipelineStateFromTechAndColor(
|
||||||
deviceCommandContext, debugCircleTech, color);
|
deviceCommandContext, debugCircleTech, color);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CCamera& camera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
const CCamera& camera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
||||||
|
|
||||||
CShaderProgramPtr debugCircleShader = debugCircleTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* debugCircleShader = debugCircleTech->GetShader();
|
||||||
debugCircleShader->Uniform(str_transform, camera.GetViewProjection());
|
debugCircleShader->Uniform(str_transform, camera.GetViewProjection());
|
||||||
debugCircleShader->Uniform(str_color, color);
|
debugCircleShader->Uniform(str_color, color);
|
||||||
|
|
||||||
@ -183,7 +183,7 @@ void CDebugRenderer::DrawCircle(const CVector3D& origin, const float radius, con
|
|||||||
debugCircleShader->AssertPointersBound();
|
debugCircleShader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||||
|
|
||||||
debugCircleTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -206,13 +206,13 @@ void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& colo
|
|||||||
|
|
||||||
CShaderTechniquePtr overlayTech =
|
CShaderTechniquePtr overlayTech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
g_Renderer.GetShaderManager().LoadEffect(str_debug_line);
|
||||||
overlayTech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
SetGraphicsPipelineStateFromTechAndColor(
|
SetGraphicsPipelineStateFromTechAndColor(
|
||||||
deviceCommandContext, overlayTech, color, true, wireframe);
|
deviceCommandContext, overlayTech, color, true, wireframe);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
CShaderProgramPtr overlayShader = overlayTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* overlayShader = overlayTech->GetShader();
|
||||||
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
overlayShader->Uniform(str_color, color);
|
overlayShader->Uniform(str_color, color);
|
||||||
|
|
||||||
@ -280,7 +280,7 @@ void CDebugRenderer::DrawCameraFrustum(const CCamera& camera, const CColor& colo
|
|||||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||||
#undef ADD
|
#undef ADD
|
||||||
|
|
||||||
overlayTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -298,13 +298,13 @@ void CDebugRenderer::DrawBoundingBox(
|
|||||||
const CMatrix3D& transform, bool wireframe)
|
const CMatrix3D& transform, bool wireframe)
|
||||||
{
|
{
|
||||||
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
||||||
shaderTech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
SetGraphicsPipelineStateFromTechAndColor(
|
SetGraphicsPipelineStateFromTechAndColor(
|
||||||
deviceCommandContext, shaderTech, color, true, wireframe);
|
deviceCommandContext, shaderTech, color, true, wireframe);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = shaderTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = shaderTech->GetShader();
|
||||||
shader->Uniform(str_color, color);
|
shader->Uniform(str_color, color);
|
||||||
shader->Uniform(str_transform, transform);
|
shader->Uniform(str_transform, transform);
|
||||||
|
|
||||||
@ -335,19 +335,19 @@ void CDebugRenderer::DrawBoundingBox(
|
|||||||
shader->AssertPointersBound();
|
shader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, 6*6);
|
deviceCommandContext->Draw(0, 6*6);
|
||||||
|
|
||||||
shaderTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CDebugRenderer::DrawBrush(const CBrush& brush, const CColor& color, bool wireframe)
|
void CDebugRenderer::DrawBrush(const CBrush& brush, const CColor& color, bool wireframe)
|
||||||
{
|
{
|
||||||
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
||||||
shaderTech->BeginPass();
|
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
SetGraphicsPipelineStateFromTechAndColor(
|
SetGraphicsPipelineStateFromTechAndColor(
|
||||||
deviceCommandContext, shaderTech, color, true, wireframe);
|
deviceCommandContext, shaderTech, color, true, wireframe);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = shaderTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = shaderTech->GetShader();
|
||||||
shader->Uniform(str_color, color);
|
shader->Uniform(str_color, color);
|
||||||
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
|
|
||||||
@ -382,6 +382,6 @@ void CDebugRenderer::DrawBrush(const CBrush& brush, const CColor& color, bool wi
|
|||||||
shader->AssertPointersBound();
|
shader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, data.size() / 5);
|
deviceCommandContext->Draw(0, data.size() / 5);
|
||||||
|
|
||||||
shaderTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -163,10 +163,10 @@ void CDecalRData::RenderDecals(
|
|||||||
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
||||||
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
techBase->BeginPass(pass);
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = techBase->GetShader(pass);
|
Renderer::Backend::GL::CShaderProgram* shader = techBase->GetShader(pass);
|
||||||
TerrainRenderer::PrepareShader(shader, shadow);
|
TerrainRenderer::PrepareShader(shader, shadow);
|
||||||
|
|
||||||
CVertexBuffer* lastVB = nullptr;
|
CVertexBuffer* lastVB = nullptr;
|
||||||
@ -225,7 +225,7 @@ void CDecalRData::RenderDecals(
|
|||||||
g_Renderer.m_Stats.m_TerrainTris += batch.indices->m_Count / 3;
|
g_Renderer.m_Stats.m_TerrainTris += batch.indices->m_Count / 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
techBase->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -190,7 +190,7 @@ void ShaderModelVertexRenderer::EndPass(
|
|||||||
// Prepare UV coordinates for this modeldef
|
// Prepare UV coordinates for this modeldef
|
||||||
void ShaderModelVertexRenderer::PrepareModelDef(
|
void ShaderModelVertexRenderer::PrepareModelDef(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, const CModelDef& def)
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, const CModelDef& def)
|
||||||
{
|
{
|
||||||
m->shadermodeldef = (ShaderModelDef*)def.GetRenderData(m);
|
m->shadermodeldef = (ShaderModelDef*)def.GetRenderData(m);
|
||||||
|
|
||||||
@ -218,7 +218,7 @@ void ShaderModelVertexRenderer::PrepareModelDef(
|
|||||||
// Render one model
|
// Render one model
|
||||||
void ShaderModelVertexRenderer::RenderModel(
|
void ShaderModelVertexRenderer::RenderModel(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data)
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, CModel* model, CModelRData* data)
|
||||||
{
|
{
|
||||||
const CModelDefPtr& mdldef = model->GetModelDef();
|
const CModelDefPtr& mdldef = model->GetModelDef();
|
||||||
ShaderModel* shadermodel = static_cast<ShaderModel*>(data);
|
ShaderModel* shadermodel = static_cast<ShaderModel*>(data);
|
||||||
|
@ -44,10 +44,10 @@ public:
|
|||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext, int streamflags) override;
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext, int streamflags) override;
|
||||||
void PrepareModelDef(
|
void PrepareModelDef(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, const CModelDef& def) override;
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, const CModelDef& def) override;
|
||||||
void RenderModel(
|
void RenderModel(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data) override;
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, CModel* model, CModelRData* data) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
struct ShaderModelRendererInternals;
|
struct ShaderModelRendererInternals;
|
||||||
|
@ -312,7 +312,7 @@ void InstancingModelRenderer::EndPass(
|
|||||||
// Prepare UV coordinates for this modeldef
|
// Prepare UV coordinates for this modeldef
|
||||||
void InstancingModelRenderer::PrepareModelDef(
|
void InstancingModelRenderer::PrepareModelDef(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, const CModelDef& def)
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, const CModelDef& def)
|
||||||
{
|
{
|
||||||
m->imodeldef = (IModelDef*)def.GetRenderData(m);
|
m->imodeldef = (IModelDef*)def.GetRenderData(m);
|
||||||
|
|
||||||
@ -377,7 +377,7 @@ void InstancingModelRenderer::PrepareModelDef(
|
|||||||
// Render one model
|
// Render one model
|
||||||
void InstancingModelRenderer::RenderModel(
|
void InstancingModelRenderer::RenderModel(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int UNUSED(streamflags), CModel* model, CModelRData* UNUSED(data))
|
Renderer::Backend::GL::CShaderProgram* shader, int UNUSED(streamflags), CModel* model, CModelRData* UNUSED(data))
|
||||||
{
|
{
|
||||||
const CModelDefPtr& mdldef = model->GetModelDef();
|
const CModelDefPtr& mdldef = model->GetModelDef();
|
||||||
|
|
||||||
|
@ -48,9 +48,9 @@ public:
|
|||||||
int streamflags);
|
int streamflags);
|
||||||
void PrepareModelDef(
|
void PrepareModelDef(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, const CModelDef& def);
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, const CModelDef& def);
|
||||||
void RenderModel(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
void RenderModel(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data);
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, CModel* model, CModelRData* data);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
InstancingModelRendererInternals* m;
|
InstancingModelRendererInternals* m;
|
||||||
|
@ -606,8 +606,8 @@ void ShaderModelRenderer::Render(
|
|||||||
// texBindings holds the identifier bindings in the shader, which can no longer be defined
|
// texBindings holds the identifier bindings in the shader, which can no longer be defined
|
||||||
// statically in the ShaderRenderModifier class. texBindingNames uses interned strings to
|
// statically in the ShaderRenderModifier class. texBindingNames uses interned strings to
|
||||||
// keep track of when bindings need to be reevaluated.
|
// keep track of when bindings need to be reevaluated.
|
||||||
using BindingListAllocator = ProxyAllocator<CShaderProgram::Binding, Arena>;
|
using BindingListAllocator = ProxyAllocator<Renderer::Backend::GL::CShaderProgram::Binding, Arena>;
|
||||||
std::vector<CShaderProgram::Binding, BindingListAllocator> texBindings((BindingListAllocator(arena)));
|
std::vector<Renderer::Backend::GL::CShaderProgram::Binding, BindingListAllocator> texBindings((BindingListAllocator(arena)));
|
||||||
texBindings.reserve(64);
|
texBindings.reserve(64);
|
||||||
|
|
||||||
using BindingNamesListAllocator = ProxyAllocator<CStrIntern, Arena>;
|
using BindingNamesListAllocator = ProxyAllocator<CStrIntern, Arena>;
|
||||||
@ -629,11 +629,11 @@ void ShaderModelRenderer::Render(
|
|||||||
// For each of the technique's passes, render all the models in this run
|
// For each of the technique's passes, render all the models in this run
|
||||||
for (int pass = 0; pass < currentTech->GetNumPasses(); ++pass)
|
for (int pass = 0; pass < currentTech->GetNumPasses(); ++pass)
|
||||||
{
|
{
|
||||||
currentTech->BeginPass(pass);
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
currentTech->GetGraphicsPipelineStateDesc(pass));
|
currentTech->GetGraphicsPipelineStateDesc(pass));
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = currentTech->GetShader(pass);
|
Renderer::Backend::GL::CShaderProgram* shader = currentTech->GetShader(pass);
|
||||||
int streamflags = shader->GetStreamFlags();
|
int streamflags = shader->GetStreamFlags();
|
||||||
|
|
||||||
modifier->BeginPass(shader);
|
modifier->BeginPass(shader);
|
||||||
@ -669,11 +669,11 @@ void ShaderModelRenderer::Render(
|
|||||||
if (currentTexs.size() != samplersNum)
|
if (currentTexs.size() != samplersNum)
|
||||||
{
|
{
|
||||||
currentTexs.resize(samplersNum, NULL);
|
currentTexs.resize(samplersNum, NULL);
|
||||||
texBindings.resize(samplersNum, CShaderProgram::Binding());
|
texBindings.resize(samplersNum, Renderer::Backend::GL::CShaderProgram::Binding());
|
||||||
texBindingNames.resize(samplersNum, CStrIntern());
|
texBindingNames.resize(samplersNum, CStrIntern());
|
||||||
|
|
||||||
// ensure they are definitely empty
|
// ensure they are definitely empty
|
||||||
std::fill(texBindings.begin(), texBindings.end(), CShaderProgram::Binding());
|
std::fill(texBindings.begin(), texBindings.end(), Renderer::Backend::GL::CShaderProgram::Binding());
|
||||||
std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)NULL);
|
std::fill(currentTexs.begin(), currentTexs.end(), (CTexture*)NULL);
|
||||||
std::fill(texBindingNames.begin(), texBindingNames.end(), CStrIntern());
|
std::fill(texBindingNames.begin(), texBindingNames.end(), CStrIntern());
|
||||||
}
|
}
|
||||||
@ -756,7 +756,7 @@ void ShaderModelRenderer::Render(
|
|||||||
|
|
||||||
m->vertexRenderer->EndPass(deviceCommandContext, streamflags);
|
m->vertexRenderer->EndPass(deviceCommandContext, streamflags);
|
||||||
|
|
||||||
currentTech->EndPass(pass);
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
idxTechStart = idxTechEnd;
|
idxTechStart = idxTechEnd;
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "graphics/MeshManager.h"
|
#include "graphics/MeshManager.h"
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgramPtr.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
|
|
||||||
class CModel;
|
class CModel;
|
||||||
class CModelRData;
|
class CModelRData;
|
||||||
@ -134,7 +135,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void PrepareModelDef(
|
virtual void PrepareModelDef(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, const CModelDef& def) = 0;
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, const CModelDef& def) = 0;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -158,7 +159,7 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual void RenderModel(
|
virtual void RenderModel(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, int streamflags, CModel* model, CModelRData* data) = 0;
|
Renderer::Backend::GL::CShaderProgram* shader, int streamflags, CModel* model, CModelRData* data) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@ -427,10 +427,10 @@ void OverlayRenderer::RenderTexturedOverlayLines(Renderer::Backend::GL::CDeviceC
|
|||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
shaderTechTexLineNormal->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
CShaderProgramPtr shaderTexLineNormal = shaderTechTexLineNormal->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shaderTexLineNormal = shaderTechTexLineNormal->GetShader();
|
||||||
|
|
||||||
shaderTexLineNormal->BindTexture(str_losTex, los.GetTexture());
|
shaderTexLineNormal->BindTexture(str_losTex, los.GetTexture());
|
||||||
shaderTexLineNormal->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
|
shaderTexLineNormal->Uniform(str_losTransform, los.GetTextureMatrix()[0], los.GetTextureMatrix()[12], 0.f, 0.f);
|
||||||
@ -440,7 +440,7 @@ void OverlayRenderer::RenderTexturedOverlayLines(Renderer::Backend::GL::CDeviceC
|
|||||||
// batch render only the non-always-visible overlay lines using the normal shader
|
// batch render only the non-always-visible overlay lines using the normal shader
|
||||||
RenderTexturedOverlayLines(deviceCommandContext, shaderTexLineNormal, false);
|
RenderTexturedOverlayLines(deviceCommandContext, shaderTexLineNormal, false);
|
||||||
|
|
||||||
shaderTechTexLineNormal->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
@ -460,10 +460,10 @@ void OverlayRenderer::RenderTexturedOverlayLines(Renderer::Backend::GL::CDeviceC
|
|||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
shaderTechTexLineAlwaysVisible->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
CShaderProgramPtr shaderTexLineAlwaysVisible = shaderTechTexLineAlwaysVisible->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shaderTexLineAlwaysVisible = shaderTechTexLineAlwaysVisible->GetShader();
|
||||||
|
|
||||||
// TODO: losTex and losTransform are unused in the always visible shader; see if these can be safely omitted
|
// TODO: losTex and losTransform are unused in the always visible shader; see if these can be safely omitted
|
||||||
shaderTexLineAlwaysVisible->BindTexture(str_losTex, los.GetTexture());
|
shaderTexLineAlwaysVisible->BindTexture(str_losTex, los.GetTexture());
|
||||||
@ -474,7 +474,7 @@ void OverlayRenderer::RenderTexturedOverlayLines(Renderer::Backend::GL::CDeviceC
|
|||||||
// batch render only the always-visible overlay lines using the LoS-ignored shader
|
// batch render only the always-visible overlay lines using the LoS-ignored shader
|
||||||
RenderTexturedOverlayLines(deviceCommandContext, shaderTexLineAlwaysVisible, true);
|
RenderTexturedOverlayLines(deviceCommandContext, shaderTexLineAlwaysVisible, true);
|
||||||
|
|
||||||
shaderTechTexLineAlwaysVisible->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------------------
|
||||||
@ -488,7 +488,7 @@ void OverlayRenderer::RenderTexturedOverlayLines(Renderer::Backend::GL::CDeviceC
|
|||||||
|
|
||||||
void OverlayRenderer::RenderTexturedOverlayLines(
|
void OverlayRenderer::RenderTexturedOverlayLines(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, bool alwaysVisible)
|
Renderer::Backend::GL::CShaderProgram* shader, bool alwaysVisible)
|
||||||
{
|
{
|
||||||
for (size_t i = 0; i < m->texlines.size(); ++i)
|
for (size_t i = 0; i < m->texlines.size(); ++i)
|
||||||
{
|
{
|
||||||
@ -530,10 +530,10 @@ void OverlayRenderer::RenderQuadOverlays(
|
|||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
shaderTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = shaderTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = shaderTech->GetShader();
|
||||||
|
|
||||||
CLOSTexture& los = g_Renderer.GetSceneRenderer().GetScene().GetLOSTexture();
|
CLOSTexture& los = g_Renderer.GetSceneRenderer().GetScene().GetLOSTexture();
|
||||||
|
|
||||||
@ -586,7 +586,7 @@ void OverlayRenderer::RenderQuadOverlays(
|
|||||||
g_Renderer.GetStats().m_OverlayTris += batchNumQuads*2;
|
g_Renderer.GetStats().m_OverlayTris += batchNumQuads*2;
|
||||||
}
|
}
|
||||||
|
|
||||||
shaderTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
// TODO: the shader should probably be responsible for unbinding its textures
|
// TODO: the shader should probably be responsible for unbinding its textures
|
||||||
deviceCommandContext->BindTexture(1, GL_TEXTURE_2D, 0);
|
deviceCommandContext->BindTexture(1, GL_TEXTURE_2D, 0);
|
||||||
@ -622,10 +622,10 @@ void OverlayRenderer::RenderForegroundOverlays(
|
|||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
if (g_Renderer.GetSceneRenderer().GetOverlayRenderMode() == WIREFRAME)
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = tech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = tech->GetShader();
|
||||||
|
|
||||||
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
|
|
||||||
@ -672,7 +672,7 @@ void OverlayRenderer::RenderForegroundOverlays(
|
|||||||
g_Renderer.GetStats().m_OverlayTris += 2;
|
g_Renderer.GetStats().m_OverlayTris += 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,7 +749,7 @@ void OverlayRenderer::RenderSphereOverlays(
|
|||||||
if (m->spheres.empty())
|
if (m->spheres.empty())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
CShaderProgramPtr shader;
|
Renderer::Backend::GL::CShaderProgram* shader;
|
||||||
CShaderTechniquePtr tech;
|
CShaderTechniquePtr tech;
|
||||||
|
|
||||||
tech = g_Renderer.GetShaderManager().LoadEffect(str_overlay_solid);
|
tech = g_Renderer.GetShaderManager().LoadEffect(str_overlay_solid);
|
||||||
@ -763,8 +763,8 @@ void OverlayRenderer::RenderSphereOverlays(
|
|||||||
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
||||||
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
shader = tech->GetShader();
|
shader = tech->GetShader();
|
||||||
|
|
||||||
@ -794,6 +794,6 @@ void OverlayRenderer::RenderSphereOverlays(
|
|||||||
g_Renderer.GetStats().m_OverlayTris = m->sphereIndexes.size()/3;
|
g_Renderer.GetStats().m_OverlayTris = m->sphereIndexes.size()/3;
|
||||||
}
|
}
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#ifndef INCLUDED_OVERLAYRENDERER
|
#ifndef INCLUDED_OVERLAYRENDERER
|
||||||
#define INCLUDED_OVERLAYRENDERER
|
#define INCLUDED_OVERLAYRENDERER
|
||||||
|
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgram.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
|
||||||
struct SOverlayLine;
|
struct SOverlayLine;
|
||||||
@ -140,7 +140,7 @@ private:
|
|||||||
*/
|
*/
|
||||||
void RenderTexturedOverlayLines(
|
void RenderTexturedOverlayLines(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, bool alwaysVisible);
|
Renderer::Backend::GL::CShaderProgram* shader, bool alwaysVisible);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper method; batch-renders all registered quad overlays, batched by their texture for effiency.
|
* Helper method; batch-renders all registered quad overlays, batched by their texture for effiency.
|
||||||
|
@ -151,11 +151,13 @@ void ParticleRenderer::RenderParticles(
|
|||||||
ENSURE(currentTech);
|
ENSURE(currentTech);
|
||||||
if (lastTech != currentTech)
|
if (lastTech != currentTech)
|
||||||
{
|
{
|
||||||
|
if (lastTech)
|
||||||
|
deviceCommandContext->EndPass();
|
||||||
lastTech = currentTech;
|
lastTech = currentTech;
|
||||||
lastTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(lastTech->GetGraphicsPipelineStateDesc());
|
deviceCommandContext->SetGraphicsPipelineState(lastTech->GetGraphicsPipelineStateDesc());
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = lastTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = lastTech->GetShader();
|
||||||
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
shader->Uniform(str_modelViewMatrix, g_Renderer.GetSceneRenderer().GetViewCamera().GetOrientation().GetInverse());
|
shader->Uniform(str_modelViewMatrix, g_Renderer.GetSceneRenderer().GetViewCamera().GetOrientation().GetInverse());
|
||||||
}
|
}
|
||||||
@ -164,7 +166,7 @@ void ParticleRenderer::RenderParticles(
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (lastTech)
|
if (lastTech)
|
||||||
lastTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
CVertexBuffer::Unbind(deviceCommandContext);
|
CVertexBuffer::Unbind(deviceCommandContext);
|
||||||
}
|
}
|
||||||
|
@ -771,10 +771,10 @@ void CPatchRData::RenderBases(
|
|||||||
const int numPasses = techBase->GetNumPasses();
|
const int numPasses = techBase->GetNumPasses();
|
||||||
for (int pass = 0; pass < numPasses; ++pass)
|
for (int pass = 0; pass < numPasses; ++pass)
|
||||||
{
|
{
|
||||||
techBase->BeginPass(pass);
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
techBase->GetGraphicsPipelineStateDesc(pass));
|
techBase->GetGraphicsPipelineStateDesc(pass));
|
||||||
const CShaderProgramPtr& shader = techBase->GetShader(pass);
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = techBase->GetShader(pass);
|
||||||
TerrainRenderer::PrepareShader(shader, shadow);
|
TerrainRenderer::PrepareShader(shader, shadow);
|
||||||
|
|
||||||
TextureBatches& textureBatches = itTech->second;
|
TextureBatches& textureBatches = itTech->second;
|
||||||
@ -827,7 +827,7 @@ void CPatchRData::RenderBases(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
techBase->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -964,7 +964,7 @@ void CPatchRData::RenderBlends(
|
|||||||
PROFILE_END("compute batches");
|
PROFILE_END("compute batches");
|
||||||
|
|
||||||
CVertexBuffer* lastVB = nullptr;
|
CVertexBuffer* lastVB = nullptr;
|
||||||
CShaderProgramPtr previousShader;
|
Renderer::Backend::GL::CShaderProgram* previousShader = nullptr;
|
||||||
for (BatchesStack::iterator itTechBegin = batches.begin(), itTechEnd = batches.begin(); itTechBegin != batches.end(); itTechBegin = itTechEnd)
|
for (BatchesStack::iterator itTechBegin = batches.begin(), itTechEnd = batches.begin(); itTechBegin != batches.end(); itTechBegin = itTechEnd)
|
||||||
{
|
{
|
||||||
while (itTechEnd != batches.end() && itTechEnd->m_ShaderTech == itTechBegin->m_ShaderTech)
|
while (itTechEnd != batches.end() && itTechEnd->m_ShaderTech == itTechBegin->m_ShaderTech)
|
||||||
@ -983,10 +983,10 @@ void CPatchRData::RenderBlends(
|
|||||||
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
Renderer::Backend::BlendFactor::ONE_MINUS_SRC_ALPHA;
|
||||||
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
pipelineStateDesc.blendState.colorBlendOp = pipelineStateDesc.blendState.alphaBlendOp =
|
||||||
Renderer::Backend::BlendOp::ADD;
|
Renderer::Backend::BlendOp::ADD;
|
||||||
techBase->BeginPass(pass);
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = techBase->GetShader(pass);
|
Renderer::Backend::GL::CShaderProgram* shader = techBase->GetShader(pass);
|
||||||
TerrainRenderer::PrepareShader(shader, shadow);
|
TerrainRenderer::PrepareShader(shader, shadow);
|
||||||
|
|
||||||
Renderer::Backend::GL::CTexture* lastBlendTex = nullptr;
|
Renderer::Backend::GL::CTexture* lastBlendTex = nullptr;
|
||||||
@ -1060,7 +1060,7 @@ void CPatchRData::RenderBlends(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
techBase->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1069,7 +1069,7 @@ void CPatchRData::RenderBlends(
|
|||||||
|
|
||||||
void CPatchRData::RenderStreams(
|
void CPatchRData::RenderStreams(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const std::vector<CPatchRData*>& patches, const CShaderProgramPtr& shader,
|
const std::vector<CPatchRData*>& patches, Renderer::Backend::GL::CShaderProgram* shader,
|
||||||
const bool bindPositionAsTexCoord)
|
const bool bindPositionAsTexCoord)
|
||||||
{
|
{
|
||||||
PROFILE3("render terrain streams");
|
PROFILE3("render terrain streams");
|
||||||
@ -1167,7 +1167,7 @@ void CPatchRData::RenderOutline()
|
|||||||
|
|
||||||
void CPatchRData::RenderSides(
|
void CPatchRData::RenderSides(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const std::vector<CPatchRData*>& patches, const CShaderProgramPtr& shader)
|
const std::vector<CPatchRData*>& patches, Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
PROFILE3("render terrain sides");
|
PROFILE3("render terrain sides");
|
||||||
GPU_SCOPED_LABEL(deviceCommandContext, "Render terrain sides");
|
GPU_SCOPED_LABEL(deviceCommandContext, "Render terrain sides");
|
||||||
@ -1430,7 +1430,7 @@ void CPatchRData::BuildWater()
|
|||||||
|
|
||||||
void CPatchRData::RenderWaterSurface(
|
void CPatchRData::RenderWaterSurface(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, const bool bindWaterData)
|
Renderer::Backend::GL::CShaderProgram* shader, const bool bindWaterData)
|
||||||
{
|
{
|
||||||
ASSERT(m_UpdateFlags == 0);
|
ASSERT(m_UpdateFlags == 0);
|
||||||
|
|
||||||
@ -1465,7 +1465,7 @@ void CPatchRData::RenderWaterSurface(
|
|||||||
|
|
||||||
void CPatchRData::RenderWaterShore(
|
void CPatchRData::RenderWaterShore(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader)
|
Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
ASSERT(m_UpdateFlags == 0);
|
ASSERT(m_UpdateFlags == 0);
|
||||||
|
|
||||||
|
@ -20,10 +20,10 @@
|
|||||||
|
|
||||||
#include "graphics/Patch.h"
|
#include "graphics/Patch.h"
|
||||||
#include "graphics/RenderableObject.h"
|
#include "graphics/RenderableObject.h"
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
|
||||||
#include "maths/Vector2D.h"
|
#include "maths/Vector2D.h"
|
||||||
#include "maths/Vector3D.h"
|
#include "maths/Vector3D.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
#include "renderer/VertexBufferManager.h"
|
#include "renderer/VertexBufferManager.h"
|
||||||
|
|
||||||
#include <vector>
|
#include <vector>
|
||||||
@ -50,10 +50,10 @@ public:
|
|||||||
|
|
||||||
void RenderWaterSurface(
|
void RenderWaterSurface(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader, const bool bindWaterData);
|
Renderer::Backend::GL::CShaderProgram* shader, const bool bindWaterData);
|
||||||
void RenderWaterShore(
|
void RenderWaterShore(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const CShaderProgramPtr& shader);
|
Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
|
|
||||||
CPatch* GetPatch() { return m_Patch; }
|
CPatch* GetPatch() { return m_Patch; }
|
||||||
|
|
||||||
@ -67,13 +67,13 @@ public:
|
|||||||
const std::vector<CPatchRData*>& patches, const CShaderDefines& context, ShadowMap* shadow);
|
const std::vector<CPatchRData*>& patches, const CShaderDefines& context, ShadowMap* shadow);
|
||||||
static void RenderStreams(
|
static void RenderStreams(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const std::vector<CPatchRData*>& patches, const CShaderProgramPtr& shader,
|
const std::vector<CPatchRData*>& patches, Renderer::Backend::GL::CShaderProgram* shader,
|
||||||
const bool bindPositionAsTexCoord);
|
const bool bindPositionAsTexCoord);
|
||||||
static void RenderSides(
|
static void RenderSides(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const std::vector<CPatchRData*>& patches, const CShaderProgramPtr& shader);
|
const std::vector<CPatchRData*>& patches, Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
|
|
||||||
static void PrepareShader(const CShaderProgramPtr& shader, ShadowMap* shadow);
|
static void PrepareShader(Renderer::Backend::GL::CShaderProgram* shader, ShadowMap* shadow);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
friend struct SBlendStackItem;
|
friend struct SBlendStackItem;
|
||||||
|
@ -197,10 +197,10 @@ void CPostprocManager::ApplyBlurDownscale2x(
|
|||||||
defines.Add(str_BLOOM_NOP, str_1);
|
defines.Add(str_BLOOM_NOP, str_1);
|
||||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines);
|
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines);
|
||||||
|
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
tech->GetGraphicsPipelineStateDesc());
|
tech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& shader = tech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = tech->GetShader();
|
||||||
|
|
||||||
shader->BindTexture(str_renderedTex, inTex);
|
shader->BindTexture(str_renderedTex, inTex);
|
||||||
|
|
||||||
@ -237,7 +237,7 @@ void CPostprocManager::ApplyBlurDownscale2x(
|
|||||||
|
|
||||||
g_Renderer.SetViewport(oldVp);
|
g_Renderer.SetViewport(oldVp);
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPostprocManager::ApplyBlurGauss(
|
void CPostprocManager::ApplyBlurGauss(
|
||||||
@ -255,10 +255,10 @@ void CPostprocManager::ApplyBlurGauss(
|
|||||||
defines2.Add(str_BLOOM_PASS_H, str_1);
|
defines2.Add(str_BLOOM_PASS_H, str_1);
|
||||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines2);
|
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines2);
|
||||||
|
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
tech->GetGraphicsPipelineStateDesc());
|
tech->GetGraphicsPipelineStateDesc());
|
||||||
CShaderProgramPtr shader = tech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = tech->GetShader();
|
||||||
shader->BindTexture(str_renderedTex, inTex);
|
shader->BindTexture(str_renderedTex, inTex);
|
||||||
shader->Uniform(str_texSize, inWidth, inHeight, 0.0f, 0.0f);
|
shader->Uniform(str_texSize, inWidth, inHeight, 0.0f, 0.0f);
|
||||||
|
|
||||||
@ -295,7 +295,7 @@ void CPostprocManager::ApplyBlurGauss(
|
|||||||
|
|
||||||
g_Renderer.SetViewport(oldVp);
|
g_Renderer.SetViewport(oldVp);
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
deviceCommandContext->SetFramebuffer(outFramebuffer);
|
deviceCommandContext->SetFramebuffer(outFramebuffer);
|
||||||
|
|
||||||
@ -303,8 +303,10 @@ void CPostprocManager::ApplyBlurGauss(
|
|||||||
CShaderDefines defines3;
|
CShaderDefines defines3;
|
||||||
defines3.Add(str_BLOOM_PASS_V, str_1);
|
defines3.Add(str_BLOOM_PASS_V, str_1);
|
||||||
tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines3);
|
tech = g_Renderer.GetShaderManager().LoadEffect(str_bloom, defines3);
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
tech->GetGraphicsPipelineStateDesc());
|
||||||
|
|
||||||
tech->BeginPass();
|
deviceCommandContext->BeginPass();
|
||||||
shader = tech->GetShader();
|
shader = tech->GetShader();
|
||||||
|
|
||||||
// Our input texture to the shader is the output of the horizontal pass.
|
// Our input texture to the shader is the output of the horizontal pass.
|
||||||
@ -322,7 +324,7 @@ void CPostprocManager::ApplyBlurGauss(
|
|||||||
|
|
||||||
g_Renderer.SetViewport(oldVp);
|
g_Renderer.SetViewport(oldVp);
|
||||||
|
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CPostprocManager::ApplyBlur(
|
void CPostprocManager::ApplyBlur(
|
||||||
@ -384,10 +386,10 @@ void CPostprocManager::ApplyEffect(
|
|||||||
deviceCommandContext->SetFramebuffer(
|
deviceCommandContext->SetFramebuffer(
|
||||||
(m_WhichBuffer ? m_PongFramebuffer : m_PingFramebuffer).get());
|
(m_WhichBuffer ? m_PongFramebuffer : m_PingFramebuffer).get());
|
||||||
|
|
||||||
shaderTech->BeginPass(pass);
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
shaderTech->GetGraphicsPipelineStateDesc(pass));
|
shaderTech->GetGraphicsPipelineStateDesc(pass));
|
||||||
const CShaderProgramPtr& shader = shaderTech->GetShader(pass);
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = shaderTech->GetShader(pass);
|
||||||
|
|
||||||
// Use the textures from the current FBO as input to the shader.
|
// Use the textures from the current FBO as input to the shader.
|
||||||
// We also bind a bunch of other textures and parameters, but since
|
// We also bind a bunch of other textures and parameters, but since
|
||||||
@ -442,7 +444,7 @@ void CPostprocManager::ApplyEffect(
|
|||||||
shader->AssertPointersBound();
|
shader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, 6);
|
deviceCommandContext->Draw(0, 6);
|
||||||
|
|
||||||
shaderTech->EndPass(pass);
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
m_WhichBuffer = !m_WhichBuffer;
|
m_WhichBuffer = !m_WhichBuffer;
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ ShaderRenderModifier::ShaderRenderModifier()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderRenderModifier::BeginPass(const CShaderProgramPtr& shader)
|
void ShaderRenderModifier::BeginPass(Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
shader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
shader->Uniform(str_cameraPos, g_Renderer.GetSceneRenderer().GetViewCamera().GetOrientation().GetTranslation());
|
shader->Uniform(str_cameraPos, g_Renderer.GetSceneRenderer().GetViewCamera().GetOrientation().GetTranslation());
|
||||||
@ -98,7 +98,7 @@ void ShaderRenderModifier::BeginPass(const CShaderProgramPtr& shader)
|
|||||||
m_BindingPlayerColor = shader->GetUniformBinding(str_playerColor);
|
m_BindingPlayerColor = shader->GetUniformBinding(str_playerColor);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShaderRenderModifier::PrepareModel(const CShaderProgramPtr& shader, CModel* model)
|
void ShaderRenderModifier::PrepareModel(Renderer::Backend::GL::CShaderProgram* shader, CModel* model)
|
||||||
{
|
{
|
||||||
if (m_BindingInstancingTransform.Active())
|
if (m_BindingInstancingTransform.Active())
|
||||||
shader->Uniform(m_BindingInstancingTransform, model->GetTransform());
|
shader->Uniform(m_BindingInstancingTransform, model->GetTransform());
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
/* Copyright (C) 2021 Wildfire Games.
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
* This file is part of 0 A.D.
|
* This file is part of 0 A.D.
|
||||||
*
|
*
|
||||||
* 0 A.D. is free software: you can redistribute it and/or modify
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
@ -60,7 +60,7 @@ public:
|
|||||||
* @return The streamflags that indicate which vertex components
|
* @return The streamflags that indicate which vertex components
|
||||||
* are required by the fragment stages (see STREAM_XYZ constants).
|
* are required by the fragment stages (see STREAM_XYZ constants).
|
||||||
*/
|
*/
|
||||||
virtual void BeginPass(const CShaderProgramPtr& shader) = 0;
|
virtual void BeginPass(Renderer::Backend::GL::CShaderProgram* shader) = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PrepareModel: Called before rendering the given model.
|
* PrepareModel: Called before rendering the given model.
|
||||||
@ -70,7 +70,7 @@ public:
|
|||||||
* @param pass The current pass number (pass == 0 is the first pass)
|
* @param pass The current pass number (pass == 0 is the first pass)
|
||||||
* @param model The model that is about to be rendered.
|
* @param model The model that is about to be rendered.
|
||||||
*/
|
*/
|
||||||
virtual void PrepareModel(const CShaderProgramPtr& shader, CModel* model) = 0;
|
virtual void PrepareModel(Renderer::Backend::GL::CShaderProgram* shader, CModel* model) = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -121,13 +121,13 @@ public:
|
|||||||
ShaderRenderModifier();
|
ShaderRenderModifier();
|
||||||
|
|
||||||
// Implementation
|
// Implementation
|
||||||
void BeginPass(const CShaderProgramPtr& shader);
|
void BeginPass(Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
void PrepareModel(const CShaderProgramPtr& shader, CModel* model);
|
void PrepareModel(Renderer::Backend::GL::CShaderProgram* shader, CModel* model);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CShaderProgram::Binding m_BindingInstancingTransform;
|
Renderer::Backend::GL::CShaderProgram::Binding m_BindingInstancingTransform;
|
||||||
CShaderProgram::Binding m_BindingShadingColor;
|
Renderer::Backend::GL::CShaderProgram::Binding m_BindingShadingColor;
|
||||||
CShaderProgram::Binding m_BindingPlayerColor;
|
Renderer::Backend::GL::CShaderProgram::Binding m_BindingPlayerColor;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_RENDERMODIFIERS
|
#endif // INCLUDED_RENDERMODIFIERS
|
||||||
|
@ -577,6 +577,8 @@ void CSceneRenderer::RenderReflections(
|
|||||||
scissorRect.height = screenScissor.y2 - screenScissor.y1;
|
scissorRect.height = screenScissor.y2 - screenScissor.y1;
|
||||||
deviceCommandContext->SetScissors(1, &scissorRect);
|
deviceCommandContext->SetScissors(1, &scissorRect);
|
||||||
|
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
|
||||||
deviceCommandContext->SetFramebuffer(wm.m_ReflectionFramebuffer.get());
|
deviceCommandContext->SetFramebuffer(wm.m_ReflectionFramebuffer.get());
|
||||||
deviceCommandContext->ClearFramebuffer();
|
deviceCommandContext->ClearFramebuffer();
|
||||||
|
|
||||||
@ -603,9 +605,6 @@ void CSceneRenderer::RenderReflections(
|
|||||||
// Reset old camera
|
// Reset old camera
|
||||||
m_ViewCamera = normalCamera;
|
m_ViewCamera = normalCamera;
|
||||||
g_Renderer.SetViewport(m_ViewCamera.GetViewPort());
|
g_Renderer.SetViewport(m_ViewCamera.GetViewPort());
|
||||||
|
|
||||||
deviceCommandContext->SetFramebuffer(
|
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// RenderRefractions: render the water refractions to the refraction texture
|
// RenderRefractions: render the water refractions to the refraction texture
|
||||||
@ -651,6 +650,8 @@ void CSceneRenderer::RenderRefractions(
|
|||||||
scissorRect.height = screenScissor.y2 - screenScissor.y1;
|
scissorRect.height = screenScissor.y2 - screenScissor.y1;
|
||||||
deviceCommandContext->SetScissors(1, &scissorRect);
|
deviceCommandContext->SetScissors(1, &scissorRect);
|
||||||
|
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
|
||||||
deviceCommandContext->SetFramebuffer(wm.m_RefractionFramebuffer.get());
|
deviceCommandContext->SetFramebuffer(wm.m_RefractionFramebuffer.get());
|
||||||
deviceCommandContext->ClearFramebuffer();
|
deviceCommandContext->ClearFramebuffer();
|
||||||
|
|
||||||
@ -670,9 +671,6 @@ void CSceneRenderer::RenderRefractions(
|
|||||||
// Reset old camera
|
// Reset old camera
|
||||||
m_ViewCamera = normalCamera;
|
m_ViewCamera = normalCamera;
|
||||||
g_Renderer.SetViewport(m_ViewCamera.GetViewPort());
|
g_Renderer.SetViewport(m_ViewCamera.GetViewPort());
|
||||||
|
|
||||||
deviceCommandContext->SetFramebuffer(
|
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void CSceneRenderer::RenderSilhouettes(
|
void CSceneRenderer::RenderSilhouettes(
|
||||||
@ -810,6 +808,9 @@ void CSceneRenderer::RenderSubmissions(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
|
||||||
|
|
||||||
CPostprocManager& postprocManager = g_Renderer.GetPostprocManager();
|
CPostprocManager& postprocManager = g_Renderer.GetPostprocManager();
|
||||||
if (postprocManager.IsEnabled())
|
if (postprocManager.IsEnabled())
|
||||||
{
|
{
|
||||||
|
@ -572,6 +572,8 @@ void ShadowMap::BeginRender()
|
|||||||
{
|
{
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext =
|
||||||
g_Renderer.GetDeviceCommandContext();
|
g_Renderer.GetDeviceCommandContext();
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
|
||||||
|
|
||||||
{
|
{
|
||||||
PROFILE("bind framebuffer");
|
PROFILE("bind framebuffer");
|
||||||
@ -629,7 +631,7 @@ void ShadowMap::EndRender()
|
|||||||
g_Renderer.SetViewport(vp);
|
g_Renderer.SetViewport(vp);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ShadowMap::BindTo(const CShaderProgramPtr& shader) const
|
void ShadowMap::BindTo(Renderer::Backend::GL::CShaderProgram* shader) const
|
||||||
{
|
{
|
||||||
if (!shader->GetTextureBinding(str_shadowTex).Active() || !m->Texture)
|
if (!shader->GetTextureBinding(str_shadowTex).Active() || !m->Texture)
|
||||||
return;
|
return;
|
||||||
@ -723,11 +725,11 @@ void ShadowMap::RenderDebugTexture(
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
CShaderTechniquePtr texTech = g_Renderer.GetShaderManager().LoadEffect(str_canvas2d);
|
CShaderTechniquePtr texTech = g_Renderer.GetShaderManager().LoadEffect(str_canvas2d);
|
||||||
texTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
texTech->GetGraphicsPipelineStateDesc());
|
texTech->GetGraphicsPipelineStateDesc());
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& texShader = texTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* texShader = texTech->GetShader();
|
||||||
|
|
||||||
texShader->Uniform(str_transform, GetDefaultGuiMatrix());
|
texShader->Uniform(str_transform, GetDefaultGuiMatrix());
|
||||||
texShader->BindTexture(str_tex, m->Texture.get());
|
texShader->BindTexture(str_tex, m->Texture.get());
|
||||||
@ -754,7 +756,7 @@ void ShadowMap::RenderDebugTexture(
|
|||||||
texShader->AssertPointersBound();
|
texShader->AssertPointersBound();
|
||||||
deviceCommandContext->Draw(0, 6);
|
deviceCommandContext->Draw(0, 6);
|
||||||
|
|
||||||
texTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
#if !CONFIG2_GLES
|
#if !CONFIG2_GLES
|
||||||
deviceCommandContext->BindTexture(0, GL_TEXTURE_2D, m->Texture->GetHandle());
|
deviceCommandContext->BindTexture(0, GL_TEXTURE_2D, m->Texture->GetHandle());
|
||||||
|
@ -18,9 +18,8 @@
|
|||||||
#ifndef INCLUDED_SHADOWMAP
|
#ifndef INCLUDED_SHADOWMAP
|
||||||
#define INCLUDED_SHADOWMAP
|
#define INCLUDED_SHADOWMAP
|
||||||
|
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
|
||||||
#include "lib/ogl.h"
|
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
|
|
||||||
class CBoundingBoxAligned;
|
class CBoundingBoxAligned;
|
||||||
class CCamera;
|
class CCamera;
|
||||||
@ -127,7 +126,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* Binds all needed resources and uniforms to draw shadows using the shader.
|
* Binds all needed resources and uniforms to draw shadows using the shader.
|
||||||
*/
|
*/
|
||||||
void BindTo(const CShaderProgramPtr& shader) const;
|
void BindTo(Renderer::Backend::GL::CShaderProgram* shader) const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Visualize shadow mapping calculations to help in
|
* Visualize shadow mapping calculations to help in
|
||||||
|
@ -470,14 +470,14 @@ void SilhouetteRenderer::RenderDebugOverlays(
|
|||||||
m = proj * m;
|
m = proj * m;
|
||||||
|
|
||||||
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
CShaderTechniquePtr shaderTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
||||||
shaderTech->BeginPass();
|
|
||||||
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
||||||
shaderTech->GetGraphicsPipelineStateDesc();
|
shaderTech->GetGraphicsPipelineStateDesc();
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
pipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
pipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
|
||||||
const CShaderProgramPtr& shader = shaderTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shader = shaderTech->GetShader();
|
||||||
shader->Uniform(str_transform, proj);
|
shader->Uniform(str_transform, proj);
|
||||||
|
|
||||||
for (size_t i = 0; i < m_DebugRects.size(); ++i)
|
for (size_t i = 0; i < m_DebugRects.size(); ++i)
|
||||||
@ -498,7 +498,7 @@ void SilhouetteRenderer::RenderDebugOverlays(
|
|||||||
deviceCommandContext->Draw(0, 6);
|
deviceCommandContext->Draw(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
shaderTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SilhouetteRenderer::EndFrame()
|
void SilhouetteRenderer::EndFrame()
|
||||||
|
@ -207,10 +207,10 @@ void SkyManager::RenderSky(
|
|||||||
|
|
||||||
CShaderTechniquePtr skytech =
|
CShaderTechniquePtr skytech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_sky_simple);
|
g_Renderer.GetShaderManager().LoadEffect(str_sky_simple);
|
||||||
skytech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
skytech->GetGraphicsPipelineStateDesc());
|
skytech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& shader = skytech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = skytech->GetShader();
|
||||||
shader->BindTexture(str_baseTex, m_SkyCubeMap.get());
|
shader->BindTexture(str_baseTex, m_SkyCubeMap.get());
|
||||||
|
|
||||||
// Translate so the sky center is at the camera space origin.
|
// Translate so the sky center is at the camera space origin.
|
||||||
@ -244,7 +244,7 @@ void SkyManager::RenderSky(
|
|||||||
|
|
||||||
deviceCommandContext->Draw(0, m_VertexArray.GetNumberOfVertices());
|
deviceCommandContext->Draw(0, m_VertexArray.GetNumberOfVertices());
|
||||||
|
|
||||||
skytech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SkyManager::CreateSkyCube()
|
void SkyManager::CreateSkyCube()
|
||||||
|
@ -221,10 +221,10 @@ void TerrainOverlay::RenderTile(
|
|||||||
pipelineStateDesc.rasterizationState.depthBiasEnabled = true;
|
pipelineStateDesc.rasterizationState.depthBiasEnabled = true;
|
||||||
pipelineStateDesc.rasterizationState.depthBiasConstantFactor = -1.0f;
|
pipelineStateDesc.rasterizationState.depthBiasConstantFactor = -1.0f;
|
||||||
pipelineStateDesc.rasterizationState.depthBiasSlopeFactor = -1.0f;
|
pipelineStateDesc.rasterizationState.depthBiasSlopeFactor = -1.0f;
|
||||||
overlayTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
CShaderProgramPtr overlayShader = overlayTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* overlayShader = overlayTech->GetShader();
|
||||||
|
|
||||||
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
overlayShader->Uniform(str_color, color);
|
overlayShader->Uniform(str_color, color);
|
||||||
@ -235,7 +235,7 @@ void TerrainOverlay::RenderTile(
|
|||||||
|
|
||||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||||
|
|
||||||
overlayTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -290,10 +290,10 @@ void TerrainOverlay::RenderTileOutline(
|
|||||||
pipelineStateDesc.rasterizationState.cullMode =
|
pipelineStateDesc.rasterizationState.cullMode =
|
||||||
drawHidden ? Renderer::Backend::CullMode::NONE : Renderer::Backend::CullMode::BACK;
|
drawHidden ? Renderer::Backend::CullMode::NONE : Renderer::Backend::CullMode::BACK;
|
||||||
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
pipelineStateDesc.rasterizationState.polygonMode = Renderer::Backend::PolygonMode::LINE;
|
||||||
overlayTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& overlayShader = overlayTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* overlayShader = overlayTech->GetShader();
|
||||||
|
|
||||||
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
overlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
overlayShader->Uniform(str_color, color);
|
overlayShader->Uniform(str_color, color);
|
||||||
@ -304,7 +304,7 @@ void TerrainOverlay::RenderTileOutline(
|
|||||||
|
|
||||||
deviceCommandContext->Draw(0, vertices.size() / 3);
|
deviceCommandContext->Draw(0, vertices.size() / 3);
|
||||||
|
|
||||||
overlayTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -178,10 +178,10 @@ void TerrainRenderer::RenderTerrainOverlayTexture(
|
|||||||
|
|
||||||
CShaderTechniquePtr debugOverlayTech =
|
CShaderTechniquePtr debugOverlayTech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_debug_overlay);
|
g_Renderer.GetShaderManager().LoadEffect(str_debug_overlay);
|
||||||
debugOverlayTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
debugOverlayTech->GetGraphicsPipelineStateDesc());
|
debugOverlayTech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& debugOverlayShader = debugOverlayTech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* debugOverlayShader = debugOverlayTech->GetShader();
|
||||||
|
|
||||||
debugOverlayShader->BindTexture(str_baseTex, texture);
|
debugOverlayShader->BindTexture(str_baseTex, texture);
|
||||||
debugOverlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
debugOverlayShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
@ -217,7 +217,7 @@ void TerrainRenderer::RenderTerrainOverlayTexture(
|
|||||||
deviceCommandContext->Draw(0, 6);
|
deviceCommandContext->Draw(0, 6);
|
||||||
}
|
}
|
||||||
|
|
||||||
debugOverlayTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -227,7 +227,7 @@ void TerrainRenderer::RenderTerrainOverlayTexture(
|
|||||||
/**
|
/**
|
||||||
* Set up all the uniforms for a shader pass.
|
* Set up all the uniforms for a shader pass.
|
||||||
*/
|
*/
|
||||||
void TerrainRenderer::PrepareShader(const CShaderProgramPtr& shader, ShadowMap* shadow)
|
void TerrainRenderer::PrepareShader(Renderer::Backend::GL::CShaderProgram* shader, ShadowMap* shadow)
|
||||||
{
|
{
|
||||||
CSceneRenderer& sceneRenderer = g_Renderer.GetSceneRenderer();
|
CSceneRenderer& sceneRenderer = g_Renderer.GetSceneRenderer();
|
||||||
|
|
||||||
@ -264,19 +264,19 @@ void TerrainRenderer::RenderTerrainShader(
|
|||||||
|
|
||||||
// render the solid black sides of the map first
|
// render the solid black sides of the map first
|
||||||
CShaderTechniquePtr techSolid = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
CShaderTechniquePtr techSolid = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
||||||
techSolid->BeginPass();
|
|
||||||
Renderer::Backend::GraphicsPipelineStateDesc solidPipelineStateDesc =
|
Renderer::Backend::GraphicsPipelineStateDesc solidPipelineStateDesc =
|
||||||
techSolid->GetGraphicsPipelineStateDesc();
|
techSolid->GetGraphicsPipelineStateDesc();
|
||||||
solidPipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
solidPipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
||||||
deviceCommandContext->SetGraphicsPipelineState(solidPipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(solidPipelineStateDesc);
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& shaderSolid = techSolid->GetShader();
|
Renderer::Backend::GL::CShaderProgram* shaderSolid = techSolid->GetShader();
|
||||||
shaderSolid->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
shaderSolid->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
shaderSolid->Uniform(str_color, 0.0f, 0.0f, 0.0f, 1.0f);
|
shaderSolid->Uniform(str_color, 0.0f, 0.0f, 0.0f, 1.0f);
|
||||||
|
|
||||||
CPatchRData::RenderSides(deviceCommandContext, visiblePatches, shaderSolid);
|
CPatchRData::RenderSides(deviceCommandContext, visiblePatches, shaderSolid);
|
||||||
|
|
||||||
techSolid->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
CPatchRData::RenderBases(deviceCommandContext, visiblePatches, context, shadow);
|
CPatchRData::RenderBases(deviceCommandContext, visiblePatches, context, shadow);
|
||||||
|
|
||||||
@ -314,16 +314,16 @@ void TerrainRenderer::RenderPatches(
|
|||||||
#else
|
#else
|
||||||
|
|
||||||
CShaderTechniquePtr solidTech = g_Renderer.GetShaderManager().LoadEffect(str_terrain_solid, defines);
|
CShaderTechniquePtr solidTech = g_Renderer.GetShaderManager().LoadEffect(str_terrain_solid, defines);
|
||||||
solidTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
solidTech->GetGraphicsPipelineStateDesc());
|
solidTech->GetGraphicsPipelineStateDesc());
|
||||||
|
deviceCommandContext->BeginPass();
|
||||||
|
|
||||||
const CShaderProgramPtr& solidShader = solidTech->GetShader();
|
Renderer::Backend::GL::CShaderProgram* solidShader = solidTech->GetShader();
|
||||||
solidShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
solidShader->Uniform(str_transform, g_Renderer.GetSceneRenderer().GetViewCamera().GetViewProjection());
|
||||||
solidShader->Uniform(str_color, color);
|
solidShader->Uniform(str_color, color);
|
||||||
|
|
||||||
CPatchRData::RenderStreams(deviceCommandContext, visiblePatches, solidShader, false);
|
CPatchRData::RenderStreams(deviceCommandContext, visiblePatches, solidShader, false);
|
||||||
solidTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -416,10 +416,10 @@ bool TerrainRenderer::RenderFancyWater(
|
|||||||
const double time = waterManager.m_WaterTexTimer;
|
const double time = waterManager.m_WaterTexTimer;
|
||||||
const float repeatPeriod = waterManager.m_RepeatPeriod;
|
const float repeatPeriod = waterManager.m_RepeatPeriod;
|
||||||
|
|
||||||
m->fancyWaterTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
m->fancyWaterTech->GetGraphicsPipelineStateDesc());
|
m->fancyWaterTech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& fancyWaterShader = m->fancyWaterTech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* fancyWaterShader = m->fancyWaterTech->GetShader();
|
||||||
|
|
||||||
const CCamera& camera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
const CCamera& camera = g_Renderer.GetSceneRenderer().GetViewCamera();
|
||||||
|
|
||||||
@ -509,7 +509,7 @@ bool TerrainRenderer::RenderFancyWater(
|
|||||||
if (waterManager.m_WaterFancyEffects)
|
if (waterManager.m_WaterFancyEffects)
|
||||||
data->RenderWaterShore(deviceCommandContext, fancyWaterShader);
|
data->RenderWaterShore(deviceCommandContext, fancyWaterShader);
|
||||||
}
|
}
|
||||||
m->fancyWaterTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -536,10 +536,10 @@ void TerrainRenderer::RenderSimpleWater(
|
|||||||
|
|
||||||
CShaderTechniquePtr waterSimpleTech =
|
CShaderTechniquePtr waterSimpleTech =
|
||||||
g_Renderer.GetShaderManager().LoadEffect(str_water_simple, context);
|
g_Renderer.GetShaderManager().LoadEffect(str_water_simple, context);
|
||||||
waterSimpleTech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
waterSimpleTech->GetGraphicsPipelineStateDesc());
|
waterSimpleTech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& waterSimpleShader = waterSimpleTech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* waterSimpleShader = waterSimpleTech->GetShader();
|
||||||
|
|
||||||
const CTexturePtr& waterTexture = waterManager.m_WaterTexture[waterManager.GetCurrentTextureIndex(1.6)];
|
const CTexturePtr& waterTexture = waterManager.m_WaterTexture[waterManager.GetCurrentTextureIndex(1.6)];
|
||||||
waterTexture->UploadBackendTextureIfNeeded(deviceCommandContext);
|
waterTexture->UploadBackendTextureIfNeeded(deviceCommandContext);
|
||||||
@ -559,7 +559,7 @@ void TerrainRenderer::RenderSimpleWater(
|
|||||||
|
|
||||||
deviceCommandContext->BindTexture(1, GL_TEXTURE_2D, 0);
|
deviceCommandContext->BindTexture(1, GL_TEXTURE_2D, 0);
|
||||||
|
|
||||||
waterSimpleTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -593,19 +593,19 @@ void TerrainRenderer::RenderWaterFoamOccluders(
|
|||||||
|
|
||||||
// Overwrite waves that would be behind the ground.
|
// Overwrite waves that would be behind the ground.
|
||||||
CShaderTechniquePtr dummyTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
CShaderTechniquePtr dummyTech = g_Renderer.GetShaderManager().LoadEffect(str_solid);
|
||||||
dummyTech->BeginPass();
|
|
||||||
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
Renderer::Backend::GraphicsPipelineStateDesc pipelineStateDesc =
|
||||||
dummyTech->GetGraphicsPipelineStateDesc();
|
dummyTech->GetGraphicsPipelineStateDesc();
|
||||||
pipelineStateDesc.depthStencilState.depthTestEnabled = true;
|
pipelineStateDesc.depthStencilState.depthTestEnabled = true;
|
||||||
pipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
pipelineStateDesc.rasterizationState.cullMode = Renderer::Backend::CullMode::NONE;
|
||||||
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
deviceCommandContext->SetGraphicsPipelineState(pipelineStateDesc);
|
||||||
const CShaderProgramPtr& dummyShader = dummyTech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* dummyShader = dummyTech->GetShader();
|
||||||
|
|
||||||
dummyShader->Uniform(str_transform, sceneRenderer.GetViewCamera().GetViewProjection());
|
dummyShader->Uniform(str_transform, sceneRenderer.GetViewCamera().GetViewProjection());
|
||||||
dummyShader->Uniform(str_color, 0.0f, 0.0f, 0.0f, 0.0f);
|
dummyShader->Uniform(str_color, 0.0f, 0.0f, 0.0f, 0.0f);
|
||||||
for (CPatchRData* data : m->visiblePatches[cullGroup])
|
for (CPatchRData* data : m->visiblePatches[cullGroup])
|
||||||
data->RenderWaterShore(deviceCommandContext, dummyShader);
|
data->RenderWaterShore(deviceCommandContext, dummyShader);
|
||||||
dummyTech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
|
|
||||||
deviceCommandContext->SetFramebuffer(
|
deviceCommandContext->SetFramebuffer(
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
#include "graphics/Color.h"
|
#include "graphics/Color.h"
|
||||||
#include "maths/BoundingBoxAligned.h"
|
#include "maths/BoundingBoxAligned.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
#include "renderer/backend/gl/Texture.h"
|
#include "renderer/backend/gl/Texture.h"
|
||||||
|
|
||||||
class CCamera;
|
class CCamera;
|
||||||
@ -186,7 +187,7 @@ private:
|
|||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
int cullGroup);
|
int cullGroup);
|
||||||
|
|
||||||
static void PrepareShader(const CShaderProgramPtr& shader, ShadowMap* shadow);
|
static void PrepareShader(Renderer::Backend::GL::CShaderProgram* shader, ShadowMap* shadow);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // INCLUDED_TERRAINRENDERER
|
#endif // INCLUDED_TERRAINRENDERER
|
||||||
|
@ -37,7 +37,7 @@
|
|||||||
|
|
||||||
void CTexturedLineRData::Render(
|
void CTexturedLineRData::Render(
|
||||||
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const SOverlayTexturedLine& line, const CShaderProgramPtr& shader)
|
const SOverlayTexturedLine& line, Renderer::Backend::GL::CShaderProgram* shader)
|
||||||
{
|
{
|
||||||
if (!m_VB || !m_VBIndices)
|
if (!m_VB || !m_VBIndices)
|
||||||
return; // might have failed to allocate
|
return; // might have failed to allocate
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
|
|
||||||
#include "graphics/Overlay.h"
|
#include "graphics/Overlay.h"
|
||||||
#include "graphics/RenderableObject.h"
|
#include "graphics/RenderableObject.h"
|
||||||
#include "graphics/ShaderProgramPtr.h"
|
#include "graphics/ShaderProgram.h"
|
||||||
#include "graphics/TextureManager.h"
|
#include "graphics/TextureManager.h"
|
||||||
#include "maths/BoundingBoxAligned.h"
|
#include "maths/BoundingBoxAligned.h"
|
||||||
#include "renderer/backend/gl/DeviceCommandContext.h"
|
#include "renderer/backend/gl/DeviceCommandContext.h"
|
||||||
@ -53,7 +53,7 @@ public:
|
|||||||
|
|
||||||
void Update(const SOverlayTexturedLine& line);
|
void Update(const SOverlayTexturedLine& line);
|
||||||
void Render(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
void Render(Renderer::Backend::GL::CDeviceCommandContext* deviceCommandContext,
|
||||||
const SOverlayTexturedLine& line, const CShaderProgramPtr& shader);
|
const SOverlayTexturedLine& line, Renderer::Backend::GL::CShaderProgram* shader);
|
||||||
|
|
||||||
bool IsVisibleInFrustum(const CFrustum& frustum) const;
|
bool IsVisibleInFrustum(const CFrustum& frustum) const;
|
||||||
|
|
||||||
|
@ -798,14 +798,16 @@ void WaterManager::RenderWaves(
|
|||||||
if (!m_WaterFancyEffects)
|
if (!m_WaterFancyEffects)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
|
Renderer::Backend::MakeDefaultGraphicsPipelineStateDesc());
|
||||||
deviceCommandContext->SetFramebuffer(m_FancyEffectsFramebuffer.get());
|
deviceCommandContext->SetFramebuffer(m_FancyEffectsFramebuffer.get());
|
||||||
deviceCommandContext->ClearFramebuffer();
|
deviceCommandContext->ClearFramebuffer();
|
||||||
|
|
||||||
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_water_waves);
|
CShaderTechniquePtr tech = g_Renderer.GetShaderManager().LoadEffect(str_water_waves);
|
||||||
tech->BeginPass();
|
|
||||||
deviceCommandContext->SetGraphicsPipelineState(
|
deviceCommandContext->SetGraphicsPipelineState(
|
||||||
tech->GetGraphicsPipelineStateDesc());
|
tech->GetGraphicsPipelineStateDesc());
|
||||||
const CShaderProgramPtr& shader = tech->GetShader();
|
deviceCommandContext->BeginPass();
|
||||||
|
Renderer::Backend::GL::CShaderProgram* shader = tech->GetShader();
|
||||||
|
|
||||||
m_WaveTex->UploadBackendTextureIfNeeded(deviceCommandContext);
|
m_WaveTex->UploadBackendTextureIfNeeded(deviceCommandContext);
|
||||||
m_FoamTex->UploadBackendTextureIfNeeded(deviceCommandContext);
|
m_FoamTex->UploadBackendTextureIfNeeded(deviceCommandContext);
|
||||||
@ -855,7 +857,7 @@ void WaterManager::RenderWaves(
|
|||||||
|
|
||||||
CVertexBuffer::Unbind(deviceCommandContext);
|
CVertexBuffer::Unbind(deviceCommandContext);
|
||||||
}
|
}
|
||||||
tech->EndPass();
|
deviceCommandContext->EndPass();
|
||||||
deviceCommandContext->SetFramebuffer(
|
deviceCommandContext->SetFramebuffer(
|
||||||
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
deviceCommandContext->GetDevice()->GetCurrentBackbuffer());
|
||||||
#endif
|
#endif
|
||||||
|
40
source/renderer/backend/IShaderProgram.h
Normal file
40
source/renderer/backend/IShaderProgram.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
|
* This file is part of 0 A.D.
|
||||||
|
*
|
||||||
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 0 A.D. is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_RENDERER_BACKEND_ISHADERPROGRAM
|
||||||
|
#define INCLUDED_RENDERER_BACKEND_ISHADERPROGRAM
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Backend
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* IShaderProgram is a container for multiple shaders of different types.
|
||||||
|
*/
|
||||||
|
class IShaderProgram
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual ~IShaderProgram() {}
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace Backend
|
||||||
|
|
||||||
|
} // namespace Renderer
|
||||||
|
|
||||||
|
#endif // INCLUDED_RENDERER_BACKEND_ISHADERPROGRAM
|
@ -31,6 +31,8 @@ GraphicsPipelineStateDesc MakeDefaultGraphicsPipelineStateDesc()
|
|||||||
{
|
{
|
||||||
GraphicsPipelineStateDesc desc{};
|
GraphicsPipelineStateDesc desc{};
|
||||||
|
|
||||||
|
desc.shaderProgram = nullptr;
|
||||||
|
|
||||||
desc.depthStencilState.depthTestEnabled = true;
|
desc.depthStencilState.depthTestEnabled = true;
|
||||||
desc.depthStencilState.depthCompareOp = CompareOp::LESS_OR_EQUAL;
|
desc.depthStencilState.depthCompareOp = CompareOp::LESS_OR_EQUAL;
|
||||||
desc.depthStencilState.depthWriteEnabled = true;
|
desc.depthStencilState.depthWriteEnabled = true;
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
#include "graphics/Color.h"
|
#include "graphics/Color.h"
|
||||||
#include "renderer/backend/CompareOp.h"
|
#include "renderer/backend/CompareOp.h"
|
||||||
|
#include "renderer/backend/IShaderProgram.h"
|
||||||
|
|
||||||
class CStr;
|
class CStr;
|
||||||
|
|
||||||
@ -159,9 +160,11 @@ struct RasterizationStateDesc
|
|||||||
float depthBiasSlopeFactor;
|
float depthBiasSlopeFactor;
|
||||||
};
|
};
|
||||||
|
|
||||||
// TODO: Add a shader program to the graphics pipeline state.
|
|
||||||
struct GraphicsPipelineStateDesc
|
struct GraphicsPipelineStateDesc
|
||||||
{
|
{
|
||||||
|
// It's a backend client reponsibility to keep the shader program alive
|
||||||
|
// while it's bound.
|
||||||
|
IShaderProgram* shaderProgram;
|
||||||
DepthStencilStateDesc depthStencilState;
|
DepthStencilStateDesc depthStencilState;
|
||||||
BlendStateDesc blendState;
|
BlendStateDesc blendState;
|
||||||
RasterizationStateDesc rasterizationState;
|
RasterizationStateDesc rasterizationState;
|
||||||
|
@ -820,6 +820,12 @@ std::unique_ptr<CBuffer> CDevice::CreateBuffer(
|
|||||||
return CBuffer::Create(this, name, type, size, dynamic);
|
return CBuffer::Create(this, name, type, size, dynamic);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::unique_ptr<CShaderProgram> CDevice::CreateShaderProgram(
|
||||||
|
const CStr& name, const CShaderDefines& defines)
|
||||||
|
{
|
||||||
|
return CShaderProgram::Create(this, name, defines);
|
||||||
|
}
|
||||||
|
|
||||||
void CDevice::Present()
|
void CDevice::Present()
|
||||||
{
|
{
|
||||||
if (m_Window)
|
if (m_Window)
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include "renderer/backend/Format.h"
|
#include "renderer/backend/Format.h"
|
||||||
#include "renderer/backend/gl/Buffer.h"
|
#include "renderer/backend/gl/Buffer.h"
|
||||||
#include "renderer/backend/gl/Framebuffer.h"
|
#include "renderer/backend/gl/Framebuffer.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
#include "renderer/backend/gl/Texture.h"
|
#include "renderer/backend/gl/Texture.h"
|
||||||
#include "scriptinterface/ScriptForward.h"
|
#include "scriptinterface/ScriptForward.h"
|
||||||
|
|
||||||
@ -98,6 +99,9 @@ public:
|
|||||||
std::unique_ptr<CBuffer> CreateBuffer(
|
std::unique_ptr<CBuffer> CreateBuffer(
|
||||||
const char* name, const CBuffer::Type type, const uint32_t size, const bool dynamic);
|
const char* name, const CBuffer::Type type, const uint32_t size, const bool dynamic);
|
||||||
|
|
||||||
|
std::unique_ptr<CShaderProgram> CreateShaderProgram(
|
||||||
|
const CStr& name, const CShaderDefines& defines);
|
||||||
|
|
||||||
void Present();
|
void Present();
|
||||||
|
|
||||||
bool IsTextureFormatSupported(const Format format) const;
|
bool IsTextureFormatSupported(const Format format) const;
|
||||||
|
@ -24,6 +24,7 @@
|
|||||||
#include "renderer/backend/gl/Device.h"
|
#include "renderer/backend/gl/Device.h"
|
||||||
#include "renderer/backend/gl/Framebuffer.h"
|
#include "renderer/backend/gl/Framebuffer.h"
|
||||||
#include "renderer/backend/gl/Mapping.h"
|
#include "renderer/backend/gl/Mapping.h"
|
||||||
|
#include "renderer/backend/gl/ShaderProgram.h"
|
||||||
#include "renderer/backend/gl/Texture.h"
|
#include "renderer/backend/gl/Texture.h"
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
@ -413,6 +414,28 @@ void CDeviceCommandContext::ResetStates()
|
|||||||
void CDeviceCommandContext::SetGraphicsPipelineStateImpl(
|
void CDeviceCommandContext::SetGraphicsPipelineStateImpl(
|
||||||
const GraphicsPipelineStateDesc& pipelineStateDesc, const bool force)
|
const GraphicsPipelineStateDesc& pipelineStateDesc, const bool force)
|
||||||
{
|
{
|
||||||
|
ENSURE(!m_InsidePass);
|
||||||
|
|
||||||
|
if (m_GraphicsPipelineStateDesc.shaderProgram != pipelineStateDesc.shaderProgram)
|
||||||
|
{
|
||||||
|
CShaderProgram* currentShaderProgram = nullptr;
|
||||||
|
if (m_GraphicsPipelineStateDesc.shaderProgram)
|
||||||
|
{
|
||||||
|
currentShaderProgram =
|
||||||
|
static_cast<CShaderProgram*>(m_GraphicsPipelineStateDesc.shaderProgram);
|
||||||
|
}
|
||||||
|
CShaderProgram* nextShaderProgram = nullptr;
|
||||||
|
if (pipelineStateDesc.shaderProgram)
|
||||||
|
{
|
||||||
|
nextShaderProgram =
|
||||||
|
static_cast<CShaderProgram*>(pipelineStateDesc.shaderProgram);
|
||||||
|
}
|
||||||
|
if (nextShaderProgram)
|
||||||
|
nextShaderProgram->Bind(currentShaderProgram);
|
||||||
|
else if (currentShaderProgram)
|
||||||
|
currentShaderProgram->Unbind();
|
||||||
|
}
|
||||||
|
|
||||||
const DepthStencilStateDesc& currentDepthStencilStateDesc = m_GraphicsPipelineStateDesc.depthStencilState;
|
const DepthStencilStateDesc& currentDepthStencilStateDesc = m_GraphicsPipelineStateDesc.depthStencilState;
|
||||||
const DepthStencilStateDesc& nextDepthStencilStateDesc = pipelineStateDesc.depthStencilState;
|
const DepthStencilStateDesc& nextDepthStencilStateDesc = pipelineStateDesc.depthStencilState;
|
||||||
if (force || currentDepthStencilStateDesc.depthTestEnabled != nextDepthStencilStateDesc.depthTestEnabled)
|
if (force || currentDepthStencilStateDesc.depthTestEnabled != nextDepthStencilStateDesc.depthTestEnabled)
|
||||||
@ -740,9 +763,23 @@ void CDeviceCommandContext::SetIndexBufferData(const void* data)
|
|||||||
m_IndexBufferData = data;
|
m_IndexBufferData = data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CDeviceCommandContext::BeginPass()
|
||||||
|
{
|
||||||
|
ENSURE(!m_InsidePass);
|
||||||
|
m_InsidePass = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CDeviceCommandContext::EndPass()
|
||||||
|
{
|
||||||
|
ENSURE(m_InsidePass);
|
||||||
|
m_InsidePass = false;
|
||||||
|
}
|
||||||
|
|
||||||
void CDeviceCommandContext::Draw(
|
void CDeviceCommandContext::Draw(
|
||||||
const uint32_t firstVertex, const uint32_t vertexCount)
|
const uint32_t firstVertex, const uint32_t vertexCount)
|
||||||
{
|
{
|
||||||
|
ENSURE(m_GraphicsPipelineStateDesc.shaderProgram);
|
||||||
|
ENSURE(m_InsidePass);
|
||||||
// Some drivers apparently don't like count = 0 in glDrawArrays here, so skip
|
// Some drivers apparently don't like count = 0 in glDrawArrays here, so skip
|
||||||
// all drawing in that case.
|
// all drawing in that case.
|
||||||
if (vertexCount == 0)
|
if (vertexCount == 0)
|
||||||
@ -753,6 +790,8 @@ void CDeviceCommandContext::Draw(
|
|||||||
void CDeviceCommandContext::DrawIndexed(
|
void CDeviceCommandContext::DrawIndexed(
|
||||||
const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset)
|
const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset)
|
||||||
{
|
{
|
||||||
|
ENSURE(m_GraphicsPipelineStateDesc.shaderProgram);
|
||||||
|
ENSURE(m_InsidePass);
|
||||||
if (indexCount == 0)
|
if (indexCount == 0)
|
||||||
return;
|
return;
|
||||||
ENSURE(m_IndexBuffer || m_IndexBufferData);
|
ENSURE(m_IndexBuffer || m_IndexBufferData);
|
||||||
@ -772,6 +811,8 @@ void CDeviceCommandContext::DrawIndexedInRange(
|
|||||||
const uint32_t firstIndex, const uint32_t indexCount,
|
const uint32_t firstIndex, const uint32_t indexCount,
|
||||||
const uint32_t start, const uint32_t end)
|
const uint32_t start, const uint32_t end)
|
||||||
{
|
{
|
||||||
|
ENSURE(m_GraphicsPipelineStateDesc.shaderProgram);
|
||||||
|
ENSURE(m_InsidePass);
|
||||||
if (indexCount == 0)
|
if (indexCount == 0)
|
||||||
return;
|
return;
|
||||||
ENSURE(m_IndexBuffer || m_IndexBufferData);
|
ENSURE(m_IndexBuffer || m_IndexBufferData);
|
||||||
|
@ -88,6 +88,9 @@ public:
|
|||||||
void SetIndexBuffer(CBuffer* buffer);
|
void SetIndexBuffer(CBuffer* buffer);
|
||||||
void SetIndexBufferData(const void* data);
|
void SetIndexBufferData(const void* data);
|
||||||
|
|
||||||
|
void BeginPass();
|
||||||
|
void EndPass();
|
||||||
|
|
||||||
void Draw(const uint32_t firstVertex, const uint32_t vertexCount);
|
void Draw(const uint32_t firstVertex, const uint32_t vertexCount);
|
||||||
void DrawIndexed(
|
void DrawIndexed(
|
||||||
const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset);
|
const uint32_t firstIndex, const uint32_t indexCount, const int32_t vertexOffset);
|
||||||
@ -130,6 +133,8 @@ private:
|
|||||||
CBuffer* m_IndexBuffer = nullptr;
|
CBuffer* m_IndexBuffer = nullptr;
|
||||||
const void* m_IndexBufferData = nullptr;
|
const void* m_IndexBufferData = nullptr;
|
||||||
|
|
||||||
|
bool m_InsidePass = false;
|
||||||
|
|
||||||
uint32_t m_ActiveTextureUnit = 0;
|
uint32_t m_ActiveTextureUnit = 0;
|
||||||
using BindUnit = std::pair<GLenum, GLuint>;
|
using BindUnit = std::pair<GLenum, GLuint>;
|
||||||
std::array<BindUnit, 16> m_BoundTextures;
|
std::array<BindUnit, 16> m_BoundTextures;
|
||||||
|
1243
source/renderer/backend/gl/ShaderProgram.cpp
Normal file
1243
source/renderer/backend/gl/ShaderProgram.cpp
Normal file
File diff suppressed because it is too large
Load Diff
216
source/renderer/backend/gl/ShaderProgram.h
Normal file
216
source/renderer/backend/gl/ShaderProgram.h
Normal file
@ -0,0 +1,216 @@
|
|||||||
|
/* Copyright (C) 2022 Wildfire Games.
|
||||||
|
* This file is part of 0 A.D.
|
||||||
|
*
|
||||||
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 2 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* 0 A.D. is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef INCLUDED_RENDERER_BACKEND_GL_SHADERPROGRAM
|
||||||
|
#define INCLUDED_RENDERER_BACKEND_GL_SHADERPROGRAM
|
||||||
|
|
||||||
|
#include "lib/ogl.h"
|
||||||
|
#include "lib/file/vfs/vfs_path.h"
|
||||||
|
#include "ps/CStrForward.h"
|
||||||
|
#include "renderer/backend/Format.h"
|
||||||
|
#include "renderer/backend/gl/Texture.h"
|
||||||
|
#include "renderer/backend/IShaderProgram.h"
|
||||||
|
|
||||||
|
#include <map>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
struct CColor;
|
||||||
|
class CMatrix3D;
|
||||||
|
class CVector3D;
|
||||||
|
class CShaderDefines;
|
||||||
|
class CStrIntern;
|
||||||
|
|
||||||
|
// Vertex data stream flags
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
STREAM_POS = (1 << 0),
|
||||||
|
STREAM_NORMAL = (1 << 1),
|
||||||
|
STREAM_COLOR = (1 << 2),
|
||||||
|
STREAM_UV0 = (1 << 3),
|
||||||
|
STREAM_UV1 = (1 << 4),
|
||||||
|
STREAM_UV2 = (1 << 5),
|
||||||
|
STREAM_UV3 = (1 << 6)
|
||||||
|
};
|
||||||
|
|
||||||
|
namespace Renderer
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace Backend
|
||||||
|
{
|
||||||
|
|
||||||
|
namespace GL
|
||||||
|
{
|
||||||
|
|
||||||
|
class CDevice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A compiled vertex+fragment shader program.
|
||||||
|
* The implementation may use GL_ARB_{vertex,fragment}_program (ARB assembly syntax)
|
||||||
|
* or GL_ARB_{vertex,fragment}_shader (GLSL), or may use hard-coded fixed-function
|
||||||
|
* multitexturing setup code; the difference is hidden from the caller.
|
||||||
|
*
|
||||||
|
* Texture/uniform IDs are typically strings, corresponding to the names defined in
|
||||||
|
* the shader .xml file. Alternatively (and more efficiently, if used very frequently),
|
||||||
|
* call GetTextureBinding/GetUniformBinding and pass its return value as the ID.
|
||||||
|
* Setting uniforms that the shader .xml doesn't support is harmless.
|
||||||
|
*
|
||||||
|
* For a high-level overview of shaders and materials, see
|
||||||
|
* http://trac.wildfiregames.com/wiki/MaterialSystem
|
||||||
|
*/
|
||||||
|
class CShaderProgram : public IShaderProgram
|
||||||
|
{
|
||||||
|
NONCOPYABLE(CShaderProgram);
|
||||||
|
|
||||||
|
public:
|
||||||
|
typedef CStrIntern attrib_id_t;
|
||||||
|
typedef CStrIntern texture_id_t;
|
||||||
|
typedef CStrIntern uniform_id_t;
|
||||||
|
typedef std::pair<int, GLenum> frag_index_pair_t;
|
||||||
|
|
||||||
|
static std::unique_ptr<CShaderProgram> Create(CDevice* device, const CStr& name, const CShaderDefines& baseDefines);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a uniform attribute or texture binding.
|
||||||
|
* For uniforms:
|
||||||
|
* - ARB shaders store vertex location in 'first', fragment location in 'second'.
|
||||||
|
* - GLSL shaders store uniform location in 'first', data type in 'second'.
|
||||||
|
* For textures, all store texture target (e.g. GL_TEXTURE_2D) in 'first', texture unit in 'second'.
|
||||||
|
* Non-existent bindings must store -1 in both.
|
||||||
|
*/
|
||||||
|
struct Binding
|
||||||
|
{
|
||||||
|
Binding(int a, int b) : first(a), second(b) { }
|
||||||
|
|
||||||
|
Binding() : first(-1), second(-1) { }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns whether this uniform attribute is active in the shader.
|
||||||
|
* If not then there's no point calling Uniform() to set its value.
|
||||||
|
*/
|
||||||
|
bool Active() const { return first != -1 || second != -1; }
|
||||||
|
|
||||||
|
int first;
|
||||||
|
int second;
|
||||||
|
};
|
||||||
|
|
||||||
|
~CShaderProgram() override;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Binds the shader into the GL context. Call this before calling Uniform()
|
||||||
|
* or trying to render with it.
|
||||||
|
*/
|
||||||
|
virtual void Bind(CShaderProgram* previousShaderProgram) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Unbinds the shader from the GL context. Call this after rendering with it.
|
||||||
|
*/
|
||||||
|
virtual void Unbind() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns bitset of STREAM_* value, indicating what vertex data streams the
|
||||||
|
* vertex shader needs (e.g. position, color, UV, ...).
|
||||||
|
*/
|
||||||
|
int GetStreamFlags() const;
|
||||||
|
|
||||||
|
|
||||||
|
virtual Binding GetTextureBinding(texture_id_t id) = 0;
|
||||||
|
|
||||||
|
// Variants of texture binding:
|
||||||
|
void BindTexture(texture_id_t id, const Renderer::Backend::GL::CTexture* tex);
|
||||||
|
void BindTexture(Binding id, const Renderer::Backend::GL::CTexture* tex);
|
||||||
|
|
||||||
|
virtual Binding GetUniformBinding(uniform_id_t id) = 0;
|
||||||
|
|
||||||
|
// Uniform-setting methods that subclasses must define:
|
||||||
|
virtual void Uniform(Binding id, float v0, float v1, float v2, float v3) = 0;
|
||||||
|
virtual void Uniform(Binding id, const CMatrix3D& v) = 0;
|
||||||
|
virtual void Uniform(Binding id, size_t count, const CMatrix3D* v) = 0;
|
||||||
|
virtual void Uniform(Binding id, size_t count, const float* v) = 0;
|
||||||
|
|
||||||
|
// Convenient uniform-setting wrappers:
|
||||||
|
|
||||||
|
void Uniform(Binding id, int v);
|
||||||
|
void Uniform(Binding id, float v);
|
||||||
|
void Uniform(Binding id, float v0, float v1);
|
||||||
|
void Uniform(Binding id, const CVector3D& v);
|
||||||
|
void Uniform(Binding id, const CColor& v);
|
||||||
|
|
||||||
|
void Uniform(uniform_id_t id, int v);
|
||||||
|
void Uniform(uniform_id_t id, float v);
|
||||||
|
void Uniform(uniform_id_t id, float v0, float v1);
|
||||||
|
void Uniform(uniform_id_t id, const CVector3D& v);
|
||||||
|
void Uniform(uniform_id_t id, const CColor& v);
|
||||||
|
void Uniform(uniform_id_t id, float v0, float v1, float v2, float v3);
|
||||||
|
void Uniform(uniform_id_t id, const CMatrix3D& v);
|
||||||
|
void Uniform(uniform_id_t id, size_t count, const CMatrix3D* v);
|
||||||
|
void Uniform(uniform_id_t id, size_t count, const float* v);
|
||||||
|
|
||||||
|
// Vertex attribute pointers (equivalent to glVertexPointer etc):
|
||||||
|
|
||||||
|
virtual void VertexPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
||||||
|
virtual void NormalPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
||||||
|
virtual void ColorPointer(const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
||||||
|
virtual void TexCoordPointer(GLenum texture, const Renderer::Backend::Format format, GLsizei stride, const void* pointer);
|
||||||
|
virtual void VertexAttribPointer(attrib_id_t id, const Renderer::Backend::Format format, GLboolean normalized, GLsizei stride, const void* pointer);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks that all the required vertex attributes have been set.
|
||||||
|
* Call this before calling Draw/DrawIndexed etc to avoid potential crashes.
|
||||||
|
*/
|
||||||
|
void AssertPointersBound();
|
||||||
|
|
||||||
|
virtual std::vector<VfsPath> GetFileDependencies() const = 0;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
CShaderProgram(int streamflags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct based on ARB vertex/fragment program files.
|
||||||
|
*/
|
||||||
|
static std::unique_ptr<CShaderProgram> ConstructARB(
|
||||||
|
CDevice* device, const VfsPath& vertexFile, const VfsPath& fragmentFile,
|
||||||
|
const CShaderDefines& defines,
|
||||||
|
const std::map<CStrIntern, int>& vertexIndexes, const std::map<CStrIntern, frag_index_pair_t>& fragmentIndexes,
|
||||||
|
int streamflags);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Construct based on GLSL vertex/fragment shader files.
|
||||||
|
*/
|
||||||
|
static std::unique_ptr<CShaderProgram> ConstructGLSL(
|
||||||
|
CDevice* device, const VfsPath& vertexFile, const VfsPath& fragmentFile,
|
||||||
|
const CShaderDefines& defines,
|
||||||
|
const std::map<CStrIntern, int>& vertexAttribs,
|
||||||
|
int streamflags);
|
||||||
|
|
||||||
|
virtual void BindTexture(texture_id_t id, GLuint tex) = 0;
|
||||||
|
virtual void BindTexture(Binding id, GLuint tex) = 0;
|
||||||
|
|
||||||
|
int m_StreamFlags;
|
||||||
|
|
||||||
|
// Non-GLSL client state handling:
|
||||||
|
void BindClientStates();
|
||||||
|
void UnbindClientStates();
|
||||||
|
int m_ValidStreams; // which streams have been specified via VertexPointer etc since the last Bind
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace GL
|
||||||
|
|
||||||
|
} // namespace Backend
|
||||||
|
|
||||||
|
} // namespace Renderer
|
||||||
|
|
||||||
|
#endif // INCLUDED_RENDERER_BACKEND_GL_SHADERPROGRAM
|
Loading…
Reference in New Issue
Block a user