diff options
author | Subv <subv2112@gmail.com> | 2018-03-27 04:42:54 +0200 |
---|---|---|
committer | James Rowe <jroweboy@gmail.com> | 2018-04-07 04:40:24 +0200 |
commit | ca96b04a0c524a1a6c3bc6952aab7d059da52c3d (patch) | |
tree | 5dcfad9d8419826601ba400e0a00fe115f5059ff | |
parent | GL: Rename PicaTexture to MaxwellTexture. (diff) | |
download | yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.gz yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.bz2 yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.lz yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.xz yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.zst yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.zip |
Diffstat (limited to '')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 39 | ||||
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.h | 21 |
2 files changed, 59 insertions, 1 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 911890f16..307c5bcc1 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -452,6 +452,45 @@ bool RasterizerOpenGL::AccelerateDisplay(const Tegra::FramebufferConfig& framebu return true; } +void RasterizerOpenGL::SamplerInfo::Create() { + sampler.Create(); + mag_filter = min_filter = Tegra::Texture::TextureFilter::Linear; + wrap_u = wrap_v = Tegra::Texture::WrapMode::Wrap; + border_color_r = border_color_g = border_color_b = border_color_a = 0; + + // default is GL_LINEAR_MIPMAP_LINEAR + glSamplerParameteri(sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + // Other attributes have correct defaults +} + +void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) { + + GLuint s = sampler.handle; + + if (mag_filter != config.mag_filter) { + mag_filter = config.mag_filter; + glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, MaxwellToGL::TextureFilterMode(mag_filter)); + } + if (min_filter != config.min_filter) { + min_filter = config.min_filter; + glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, MaxwellToGL::TextureFilterMode(min_filter)); + } + + if (wrap_u != config.wrap_u) { + wrap_u = config.wrap_u; + glSamplerParameteri(s, GL_TEXTURE_WRAP_S, MaxwellToGL::WrapMode(wrap_u)); + } + if (wrap_v != config.wrap_v) { + wrap_v = config.wrap_v; + glSamplerParameteri(s, GL_TEXTURE_WRAP_T, MaxwellToGL::WrapMode(wrap_v)); + } + + if (wrap_u == Tegra::Texture::WrapMode::Border || wrap_v == Tegra::Texture::WrapMode::Border) { + // TODO(Subv): Implement border color + ASSERT(false); + } +} + void RasterizerOpenGL::SetShader() { // TODO(bunnei): The below sets up a static test shader for passing untransformed vertices to // OpenGL for rendering. This should be removed/replaced when we start emulating Maxwell diff --git a/src/video_core/renderer_opengl/gl_rasterizer.h b/src/video_core/renderer_opengl/gl_rasterizer.h index fd53e94cd..ba2113921 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.h +++ b/src/video_core/renderer_opengl/gl_rasterizer.h @@ -85,7 +85,26 @@ public: "FSUniformData structure must be less than 16kb as per the OpenGL spec"); private: - struct SamplerInfo {}; + class SamplerInfo { + public: + OGLSampler sampler; + + /// Creates the sampler object, initializing its state so that it's in sync with the + /// SamplerInfo struct. + void Create(); + /// Syncs the sampler object with the config, updating any necessary state. + void SyncWithConfig(const Tegra::Texture::TSCEntry& config); + + private: + Tegra::Texture::TextureFilter mag_filter; + Tegra::Texture::TextureFilter min_filter; + Tegra::Texture::WrapMode wrap_u; + Tegra::Texture::WrapMode wrap_v; + u32 border_color_r; + u32 border_color_g; + u32 border_color_b; + u32 border_color_a; + }; /// Binds the framebuffer color and depth surface void BindFramebufferSurfaces(const Surface& color_surface, const Surface& depth_surface, |