Clean more legacy code (#3478)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
@@ -5,10 +5,8 @@
|
||||
#include <mbgl/gfx/command_encoder.hpp>
|
||||
#include <mbgl/gfx/context_observer.hpp>
|
||||
#include <mbgl/gfx/draw_scope.hpp>
|
||||
#include <mbgl/gfx/program.hpp>
|
||||
#include <mbgl/gfx/renderbuffer.hpp>
|
||||
#include <mbgl/gfx/rendering_stats.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/types.hpp>
|
||||
|
||||
#include <mbgl/gfx/uniform_buffer.hpp>
|
||||
@@ -30,6 +28,8 @@ using RenderTargetPtr = std::shared_ptr<RenderTarget>;
|
||||
|
||||
namespace gfx {
|
||||
|
||||
class DepthMode;
|
||||
class ColorMode;
|
||||
class OffscreenTexture;
|
||||
class ShaderRegistry;
|
||||
|
||||
@@ -79,13 +79,6 @@ public:
|
||||
|
||||
virtual std::unique_ptr<OffscreenTexture> createOffscreenTexture(Size, TextureChannelDataType) = 0;
|
||||
|
||||
/// Creates an empty texture with the specified dimensions.
|
||||
Texture createTexture(const Size size,
|
||||
TexturePixelType format = TexturePixelType::RGBA,
|
||||
TextureChannelDataType type = TextureChannelDataType::UnsignedByte) {
|
||||
return {size, createTextureResource(size, format, type)};
|
||||
}
|
||||
|
||||
template <RenderbufferPixelType pixelType>
|
||||
Renderbuffer<pixelType> createRenderbuffer(const Size size) {
|
||||
return {size, createRenderbufferResource(pixelType, size)};
|
||||
@@ -173,7 +166,6 @@ public:
|
||||
virtual void unbindGlobalUniformBuffers(gfx::RenderPass&) const noexcept = 0;
|
||||
|
||||
protected:
|
||||
virtual std::unique_ptr<TextureResource> createTextureResource(Size, TexturePixelType, TextureChannelDataType) = 0;
|
||||
virtual std::unique_ptr<RenderbufferResource> createRenderbufferResource(RenderbufferPixelType, Size) = 0;
|
||||
virtual std::unique_ptr<DrawScopeResource> createDrawScopeResource() = 0;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/shaders/segment.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
namespace gfx {
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
#include <mbgl/style/types.hpp>
|
||||
#include <mbgl/gfx/vertex_vector.hpp>
|
||||
#include <mbgl/gfx/index_vector.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/shaders/segment.hpp>
|
||||
#include <mbgl/util/math.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
@@ -15,6 +15,8 @@ class Context;
|
||||
class UploadPass;
|
||||
class TextureResource;
|
||||
|
||||
constexpr int32_t MaxActiveTextureUnits = 8;
|
||||
|
||||
class Texture2D {
|
||||
public:
|
||||
struct SamplerState {
|
||||
|
||||
@@ -4,14 +4,12 @@
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/gl/vertex_array.hpp>
|
||||
#include <mbgl/gl/vertex_attribute_gl.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
template <class AttributeList>
|
||||
class Segment;
|
||||
class SegmentBase;
|
||||
class PaintParameters;
|
||||
|
||||
namespace gfx {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/texture2d.hpp>
|
||||
#include <mbgl/gl/object.hpp>
|
||||
#include <mbgl/platform/gl_functions.hpp>
|
||||
#include <mbgl/util/image.hpp>
|
||||
|
||||
@@ -66,7 +67,7 @@ private:
|
||||
|
||||
private:
|
||||
gl::Context& context;
|
||||
std::unique_ptr<gfx::TextureResource> textureResource{nullptr};
|
||||
std::unique_ptr<UniqueTexture> texture;
|
||||
|
||||
SamplerState samplerState{};
|
||||
gfx::TexturePixelType pixelFormat{gfx::TexturePixelType::RGBA};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/gfx/depth_mode.hpp>
|
||||
#include <mbgl/gfx/stencil_mode.hpp>
|
||||
@@ -109,10 +108,6 @@ public:
|
||||
|
||||
std::unique_ptr<gfx::OffscreenTexture> createOffscreenTexture(Size, gfx::TextureChannelDataType) override;
|
||||
|
||||
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
|
||||
std::unique_ptr<gfx::RenderbufferResource> createRenderbufferResource(gfx::RenderbufferPixelType,
|
||||
Size size) override;
|
||||
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <mbgl/gfx/drawable.hpp>
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/mtl/upload_pass.hpp>
|
||||
#include <mbgl/programs/segment.hpp>
|
||||
#include <mbgl/shaders/segment.hpp>
|
||||
|
||||
#include <memory>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/gfx/renderbuffer.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/upload_pass.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
#include <mbgl/mtl/mtl_fwd.hpp>
|
||||
@@ -71,21 +70,6 @@ public:
|
||||
const std::optional<std::chrono::duration<double>> lastUpdate,
|
||||
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override;
|
||||
|
||||
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,
|
||||
const void* data,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
void updateTextureResource(
|
||||
gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override;
|
||||
|
||||
void updateTextureResourceSub(gfx::TextureResource&,
|
||||
uint16_t xOffset,
|
||||
uint16_t yOffset,
|
||||
Size,
|
||||
const void* data,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
|
||||
private:
|
||||
void pushDebugGroup(const char* name) override;
|
||||
void popDebugGroup() override;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/shaders/gl/shader_program_gl.hpp>
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/shaders/program_parameters.hpp>
|
||||
#include <mbgl/util/containers.hpp>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/shaders/mtl/common.hpp>
|
||||
#include <mbgl/shaders/mtl/shader_program.hpp>
|
||||
#include <mbgl/shaders/program_parameters.hpp>
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
#include <mbgl/util/containers.hpp>
|
||||
|
||||
89
include/mbgl/shaders/program_parameters.hpp
Normal file
89
include/mbgl/shaders/program_parameters.hpp
Normal file
@@ -0,0 +1,89 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/backend.hpp>
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
#include <string>
|
||||
#include <unordered_map>
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class ProgramParameters {
|
||||
public:
|
||||
struct ProgramSource {
|
||||
gfx::Backend::Type backend{gfx::Backend::Type::TYPE_MAX};
|
||||
std::string vertex;
|
||||
std::string fragment;
|
||||
|
||||
ProgramSource() = default;
|
||||
|
||||
/// @brief Construct a new ProgramSource object
|
||||
/// @param forBackend The provided source code is intended for use with the given rendering backend.
|
||||
/// @param vertex_ The vertex shader source code, or empty string if not provided.
|
||||
/// @param fragment_ The fragment shader source code, or empty string if not provided.
|
||||
ProgramSource(gfx::Backend::Type forBackend, const std::string& vertex_, const std::string& fragment_)
|
||||
: backend(forBackend),
|
||||
vertex(vertex_),
|
||||
fragment(fragment_) {
|
||||
assert(gfx::Backend::Type::TYPE_MAX != forBackend);
|
||||
}
|
||||
};
|
||||
|
||||
ProgramParameters(float pixelRatio, bool overdraw);
|
||||
|
||||
/// @brief Provide custom shader code which overrides any default source present
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withShaderSource(const ProgramSource& source) const noexcept;
|
||||
|
||||
/// @brief Provide default shader source
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withDefaultSource(const ProgramSource& source) const noexcept;
|
||||
|
||||
/// @brief Provide a `BuiltIn` value used to indicate the program type
|
||||
/// @param source ProgramSource
|
||||
/// @return Mutated ProgramParameters
|
||||
ProgramParameters withProgramType(shaders::BuiltIn type) const noexcept;
|
||||
|
||||
shaders::BuiltIn getProgramType() const noexcept { return programType; }
|
||||
|
||||
/// @brief Get a list of built-in shader preprocessor defines
|
||||
/// @return Shader source string
|
||||
/// @todo With the addition of future backends, defines should also be backend-aware
|
||||
const std::string& getDefinesString() const;
|
||||
|
||||
/// @brief Get a list of built-in shader preprocessor defines
|
||||
/// @return Map of key-value pairs representing preprocessor definitions
|
||||
const std::unordered_map<std::string, std::string>& getDefines() const { return defines; }
|
||||
|
||||
/// @brief Get source code for the vertex shader compatible with the requested backend
|
||||
/// @param backend Backend type
|
||||
/// @return Shader source string
|
||||
const std::string& vertexSource(gfx::Backend::Type backend) const;
|
||||
|
||||
/// @brief Get source code for the fragment shader compatible with the requested backend
|
||||
/// @param backend Backend type
|
||||
/// @return Shader source string
|
||||
const std::string& fragmentSource(gfx::Backend::Type backend) const;
|
||||
|
||||
bool getOverdrawInspectorEnabled() const { return overdrawInspector; }
|
||||
std::uint64_t getDefinesHash() const { return definesHash; }
|
||||
|
||||
private:
|
||||
std::unordered_map<std::string, std::string> defines;
|
||||
std::uint64_t definesHash;
|
||||
shaders::BuiltIn programType = shaders::BuiltIn::None;
|
||||
|
||||
// cached value of `defines` converted to string format
|
||||
mutable std::string definesStr;
|
||||
|
||||
std::array<ProgramSource, static_cast<size_t>(gfx::Backend::Type::TYPE_MAX)> defaultSources;
|
||||
std::array<ProgramSource, static_cast<size_t>(gfx::Backend::Type::TYPE_MAX)> userSources;
|
||||
|
||||
bool overdrawInspector;
|
||||
};
|
||||
|
||||
} // namespace mbgl
|
||||
@@ -1,8 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/shader_group.hpp>
|
||||
#include <mbgl/programs/program_parameters.hpp>
|
||||
#include <mbgl/shaders/vulkan/shader_program.hpp>
|
||||
#include <mbgl/shaders/program_parameters.hpp>
|
||||
#include <mbgl/shaders/shader_source.hpp>
|
||||
#include <mbgl/util/hash.hpp>
|
||||
#include <mbgl/util/containers.hpp>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/gfx/depth_mode.hpp>
|
||||
#include <mbgl/gfx/stencil_mode.hpp>
|
||||
@@ -105,10 +104,6 @@ public:
|
||||
|
||||
std::unique_ptr<gfx::OffscreenTexture> createOffscreenTexture(Size, gfx::TextureChannelDataType) override;
|
||||
|
||||
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
|
||||
std::unique_ptr<gfx::RenderbufferResource> createRenderbufferResource(gfx::RenderbufferPixelType,
|
||||
Size size) override;
|
||||
|
||||
|
||||
@@ -3,6 +3,7 @@
|
||||
#include <mbgl/vulkan/renderer_backend.hpp>
|
||||
#include <mbgl/gfx/draw_mode.hpp>
|
||||
#include <mbgl/gfx/color_mode.hpp>
|
||||
#include <mbgl/gfx/cull_face_mode.hpp>
|
||||
#include <mbgl/gfx/depth_mode.hpp>
|
||||
#include <mbgl/gfx/stencil_mode.hpp>
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
|
||||
#include <mbgl/gfx/index_buffer.hpp>
|
||||
#include <mbgl/gfx/renderbuffer.hpp>
|
||||
#include <mbgl/gfx/texture.hpp>
|
||||
#include <mbgl/gfx/upload_pass.hpp>
|
||||
#include <mbgl/gfx/vertex_buffer.hpp>
|
||||
|
||||
@@ -66,21 +65,6 @@ public:
|
||||
const std::optional<std::chrono::duration<double>> lastUpdate,
|
||||
/*out*/ std::vector<std::unique_ptr<gfx::VertexBufferResource>>& outBuffers) override;
|
||||
|
||||
std::unique_ptr<gfx::TextureResource> createTextureResource(Size,
|
||||
const void* data,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
void updateTextureResource(
|
||||
gfx::TextureResource&, Size, const void* data, gfx::TexturePixelType, gfx::TextureChannelDataType) override;
|
||||
|
||||
void updateTextureResourceSub(gfx::TextureResource&,
|
||||
uint16_t xOffset,
|
||||
uint16_t yOffset,
|
||||
Size,
|
||||
const void* data,
|
||||
gfx::TexturePixelType,
|
||||
gfx::TextureChannelDataType) override;
|
||||
|
||||
private:
|
||||
void pushDebugGroup(const char* name) override;
|
||||
void popDebugGroup() override;
|
||||
|
||||
Reference in New Issue
Block a user