diff options
| author | 2018-03-26 21:42:54 -0500 | |
|---|---|---|
| committer | 2018-04-06 20:40:24 -0600 | |
| commit | ca96b04a0c524a1a6c3bc6952aab7d059da52c3d (patch) | |
| tree | 5dcfad9d8419826601ba400e0a00fe115f5059ff /src | |
| parent | GL: Rename PicaTexture to MaxwellTexture. (diff) | |
| download | yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.gz yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.tar.xz yuzu-ca96b04a0c524a1a6c3bc6952aab7d059da52c3d.zip | |
GL: Ported the SamplerInfo struct from citra.
Diffstat (limited to 'src')
| -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 | |||
| 452 | return true; | 452 | return true; |
| 453 | } | 453 | } |
| 454 | 454 | ||
| 455 | void RasterizerOpenGL::SamplerInfo::Create() { | ||
| 456 | sampler.Create(); | ||
| 457 | mag_filter = min_filter = Tegra::Texture::TextureFilter::Linear; | ||
| 458 | wrap_u = wrap_v = Tegra::Texture::WrapMode::Wrap; | ||
| 459 | border_color_r = border_color_g = border_color_b = border_color_a = 0; | ||
| 460 | |||
| 461 | // default is GL_LINEAR_MIPMAP_LINEAR | ||
| 462 | glSamplerParameteri(sampler.handle, GL_TEXTURE_MIN_FILTER, GL_LINEAR); | ||
| 463 | // Other attributes have correct defaults | ||
| 464 | } | ||
| 465 | |||
| 466 | void RasterizerOpenGL::SamplerInfo::SyncWithConfig(const Tegra::Texture::TSCEntry& config) { | ||
| 467 | |||
| 468 | GLuint s = sampler.handle; | ||
| 469 | |||
| 470 | if (mag_filter != config.mag_filter) { | ||
| 471 | mag_filter = config.mag_filter; | ||
| 472 | glSamplerParameteri(s, GL_TEXTURE_MAG_FILTER, MaxwellToGL::TextureFilterMode(mag_filter)); | ||
| 473 | } | ||
| 474 | if (min_filter != config.min_filter) { | ||
| 475 | min_filter = config.min_filter; | ||
| 476 | glSamplerParameteri(s, GL_TEXTURE_MIN_FILTER, MaxwellToGL::TextureFilterMode(min_filter)); | ||
| 477 | } | ||
| 478 | |||
| 479 | if (wrap_u != config.wrap_u) { | ||
| 480 | wrap_u = config.wrap_u; | ||
| 481 | glSamplerParameteri(s, GL_TEXTURE_WRAP_S, MaxwellToGL::WrapMode(wrap_u)); | ||
| 482 | } | ||
| 483 | if (wrap_v != config.wrap_v) { | ||
| 484 | wrap_v = config.wrap_v; | ||
| 485 | glSamplerParameteri(s, GL_TEXTURE_WRAP_T, MaxwellToGL::WrapMode(wrap_v)); | ||
| 486 | } | ||
| 487 | |||
| 488 | if (wrap_u == Tegra::Texture::WrapMode::Border || wrap_v == Tegra::Texture::WrapMode::Border) { | ||
| 489 | // TODO(Subv): Implement border color | ||
| 490 | ASSERT(false); | ||
| 491 | } | ||
| 492 | } | ||
| 493 | |||
| 455 | void RasterizerOpenGL::SetShader() { | 494 | void RasterizerOpenGL::SetShader() { |
| 456 | // TODO(bunnei): The below sets up a static test shader for passing untransformed vertices to | 495 | // TODO(bunnei): The below sets up a static test shader for passing untransformed vertices to |
| 457 | // OpenGL for rendering. This should be removed/replaced when we start emulating Maxwell | 496 | // 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: | |||
| 85 | "FSUniformData structure must be less than 16kb as per the OpenGL spec"); | 85 | "FSUniformData structure must be less than 16kb as per the OpenGL spec"); |
| 86 | 86 | ||
| 87 | private: | 87 | private: |
| 88 | struct SamplerInfo {}; | 88 | class SamplerInfo { |
| 89 | public: | ||
| 90 | OGLSampler sampler; | ||
| 91 | |||
| 92 | /// Creates the sampler object, initializing its state so that it's in sync with the | ||
| 93 | /// SamplerInfo struct. | ||
| 94 | void Create(); | ||
| 95 | /// Syncs the sampler object with the config, updating any necessary state. | ||
| 96 | void SyncWithConfig(const Tegra::Texture::TSCEntry& config); | ||
| 97 | |||
| 98 | private: | ||
| 99 | Tegra::Texture::TextureFilter mag_filter; | ||
| 100 | Tegra::Texture::TextureFilter min_filter; | ||
| 101 | Tegra::Texture::WrapMode wrap_u; | ||
| 102 | Tegra::Texture::WrapMode wrap_v; | ||
| 103 | u32 border_color_r; | ||
| 104 | u32 border_color_g; | ||
| 105 | u32 border_color_b; | ||
| 106 | u32 border_color_a; | ||
| 107 | }; | ||
| 89 | 108 | ||
| 90 | /// Binds the framebuffer color and depth surface | 109 | /// Binds the framebuffer color and depth surface |
| 91 | void BindFramebufferSurfaces(const Surface& color_surface, const Surface& depth_surface, | 110 | void BindFramebufferSurfaces(const Surface& color_surface, const Surface& depth_surface, |