[core] update native for line property function shaders changes (#6658)
* [core] update shaders for line property functions update deps, define device pixel ratio for all shaders [core] create ShaderParameter struct to store pixel ratio and overdraw param repair rebase errs update shaders to include pixel ratio make sure collision_box never overdraws update test suite, move shaders to Painter::render so the correct pixel ratio is applied move shader compiling back to the Painter constructor rebase from shader --> program refactor re-factor parameters for collisionBox and debug programs remove unused vars from line-program, move blur math to shader update core files remove unecessary files update shaders PR, remove comments bump test suite sha fix formatting, incorporate feedback refactor program.hpp * [core] remove line transformations that were moved to the shaders, bump shader sha * [core] shorten ProgramParameter instantiation * [core] bump shader+test suite shas
This commit is contained in:
@@ -1,33 +1,38 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gl/program.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
|
||||
#include <cassert>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
enum class ProgramDefines : bool {
|
||||
None = false,
|
||||
Overdraw = true,
|
||||
};
|
||||
|
||||
template <class Shaders, class Primitive, class Attributes, class Uniforms>
|
||||
class Program : public gl::Program<Primitive, Attributes, Uniforms> {
|
||||
public:
|
||||
using ParentType = gl::Program<Primitive, Attributes, Uniforms>;
|
||||
|
||||
Program(gl::Context& context, ProgramDefines defines)
|
||||
: ParentType(context, Shaders::vertexSource, fragmentSource(defines))
|
||||
Program(gl::Context& context, const ProgramParameters& programParameters)
|
||||
: ParentType(context, vertexSource(programParameters), fragmentSource(programParameters))
|
||||
{}
|
||||
|
||||
static std::string fragmentSource(ProgramDefines defines) {
|
||||
std::string fragment = Shaders::fragmentSource;
|
||||
if (defines == ProgramDefines::Overdraw) {
|
||||
assert(fragment.find("#ifdef OVERDRAW_INSPECTOR") != std::string::npos);
|
||||
fragment.replace(fragment.find_first_of('\n'), 1, "\n#define OVERDRAW_INSPECTOR\n");
|
||||
}
|
||||
return fragment;
|
||||
|
||||
static std::string pixelRatioDefine(const ProgramParameters& parameters) {
|
||||
return std::string("#define DEVICE_PIXEL_RATIO ") + std::to_string(parameters.pixelRatio) + "\n";
|
||||
}
|
||||
|
||||
static std::string fragmentSource(const ProgramParameters& parameters) {
|
||||
std::string source = pixelRatioDefine(parameters) + Shaders::fragmentSource;
|
||||
if (parameters.overdraw) {
|
||||
assert(source.find("#ifdef OVERDRAW_INSPECTOR") != std::string::npos);
|
||||
source.replace(source.find_first_of('\n'), 1, "\n#define OVERDRAW_INSPECTOR\n");
|
||||
}
|
||||
return source;
|
||||
}
|
||||
|
||||
static std::string vertexSource(const ProgramParameters& parameters) {
|
||||
return pixelRatioDefine(parameters) + Shaders::vertexSource;
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user