diff options
| author | Fernando S <fsahmkow27@gmail.com> | 2024-02-02 15:08:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-02 15:08:06 +0100 |
| commit | 58cf2ee1f93ebfa0e6b25b71d349ad2ad7895f53 (patch) | |
| tree | a6efdfb4de7a7bac87926f6f1e93e7275634c731 /src/video_core/renderer_opengl/present/util.h | |
| parent | 3212bf529428f4dc45ccce550c956276557c52fb (diff) | |
| parent | 2c421a7046c5ff1fdb8319f097a89a331907baf6 (diff) | |
Merge pull request #12761 from liamwhite/mp-composite
video_core: rewrite presentation for layer composition
Diffstat (limited to 'src/video_core/renderer_opengl/present/util.h')
| -rw-r--r-- | src/video_core/renderer_opengl/present/util.h | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/src/video_core/renderer_opengl/present/util.h b/src/video_core/renderer_opengl/present/util.h new file mode 100644 index 000000000..67f03aa27 --- /dev/null +++ b/src/video_core/renderer_opengl/present/util.h @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: Copyright 2024 yuzu Emulator Project +// SPDX-License-Identifier: GPL-2.0-or-later + +#pragma once + +#include <string> + +#include "common/assert.h" +#include "video_core/renderer_opengl/gl_resource_manager.h" + +namespace OpenGL { + +static inline void ReplaceInclude(std::string& shader_source, std::string_view include_name, + std::string_view include_content) { + const std::string include_string = fmt::format("#include \"{}\"", include_name); + const std::size_t pos = shader_source.find(include_string); + ASSERT(pos != std::string::npos); + shader_source.replace(pos, include_string.size(), include_content); +}; + +static inline OGLSampler CreateBilinearSampler() { + OGLSampler sampler; + sampler.Create(); + glSamplerParameteri(sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glSamplerParameteri(sampler.handle, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + return sampler; +} + +static inline OGLSampler CreateNearestNeighborSampler() { + OGLSampler sampler; + sampler.Create(); + glSamplerParameteri(sampler.handle, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glSamplerParameteri(sampler.handle, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glSamplerParameteri(sampler.handle, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); + return sampler; +} + +} // namespace OpenGL |
