summaryrefslogtreecommitdiffstats
path: root/src/video_core/renderer_opengl/gl_shader_gen.h
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2018-08-19 19:54:19 +0200
committerSubv <subv2112@gmail.com>2018-08-19 19:57:54 +0200
commit3ef4b3d4b445960576f10d1ba6521580d03e3da8 (patch)
tree095841351b74f05ec43dd63754b9aa342e261b4c /src/video_core/renderer_opengl/gl_shader_gen.h
parentShader: Added bitfields for the texture type of the various sampling instructions. (diff)
downloadyuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar.gz
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar.bz2
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar.lz
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar.xz
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.tar.zst
yuzu-3ef4b3d4b445960576f10d1ba6521580d03e3da8.zip
Diffstat (limited to 'src/video_core/renderer_opengl/gl_shader_gen.h')
-rw-r--r--src/video_core/renderer_opengl/gl_shader_gen.h50
1 files changed, 44 insertions, 6 deletions
diff --git a/src/video_core/renderer_opengl/gl_shader_gen.h b/src/video_core/renderer_opengl/gl_shader_gen.h
index 4729ce0fc..db48da645 100644
--- a/src/video_core/renderer_opengl/gl_shader_gen.h
+++ b/src/video_core/renderer_opengl/gl_shader_gen.h
@@ -11,6 +11,7 @@
#include <vector>
#include "common/common_types.h"
#include "common/hash.h"
+#include "video_core/engines/shader_bytecode.h"
namespace GLShader {
@@ -72,8 +73,9 @@ class SamplerEntry {
using Maxwell = Tegra::Engines::Maxwell3D::Regs;
public:
- SamplerEntry(Maxwell::ShaderStage stage, size_t offset, size_t index)
- : offset(offset), stage(stage), sampler_index(index) {}
+ SamplerEntry(Maxwell::ShaderStage stage, size_t offset, size_t index,
+ Tegra::Shader::TextureType type, bool is_array)
+ : offset(offset), stage(stage), sampler_index(index), type(type), is_array(is_array) {}
size_t GetOffset() const {
return offset;
@@ -88,8 +90,41 @@ public:
}
std::string GetName() const {
- return std::string(TextureSamplerNames[static_cast<size_t>(stage)]) + '[' +
- std::to_string(sampler_index) + ']';
+ return std::string(TextureSamplerNames[static_cast<size_t>(stage)]) + '_' +
+ std::to_string(sampler_index);
+ }
+
+ std::string GetTypeString() const {
+ using Tegra::Shader::TextureType;
+ std::string glsl_type;
+
+ switch (type) {
+ case TextureType::Texture1D:
+ glsl_type = "sampler1D";
+ break;
+ case TextureType::Texture2D:
+ glsl_type = "sampler2D";
+ break;
+ case TextureType::Texture3D:
+ glsl_type = "sampler3D";
+ break;
+ case TextureType::TextureCube:
+ glsl_type = "samplerCube";
+ break;
+ default:
+ UNIMPLEMENTED();
+ }
+ if (is_array)
+ glsl_type += "Array";
+ return glsl_type;
+ }
+
+ Tegra::Shader::TextureType GetType() const {
+ return type;
+ }
+
+ bool IsArray() const {
+ return is_array;
}
static std::string GetArrayName(Maxwell::ShaderStage stage) {
@@ -100,11 +135,14 @@ private:
static constexpr std::array<const char*, Maxwell::MaxShaderStage> TextureSamplerNames = {
"tex_vs", "tex_tessc", "tex_tesse", "tex_gs", "tex_fs",
};
+
/// Offset in TSC memory from which to read the sampler object, as specified by the sampling
/// instruction.
size_t offset;
- Maxwell::ShaderStage stage; ///< Shader stage where this sampler was used.
- size_t sampler_index; ///< Value used to index into the generated GLSL sampler array.
+ Maxwell::ShaderStage stage; ///< Shader stage where this sampler was used.
+ size_t sampler_index; ///< Value used to index into the generated GLSL sampler array.
+ Tegra::Shader::TextureType type; ///< The type used to sample this texture (Texture2D, etc)
+ bool is_array; ///< Whether the texture is being sampled as an array texture or not.
};
struct ShaderEntries {