diff options
| author | 2021-07-31 03:04:08 -0300 | |
|---|---|---|
| committer | 2021-11-16 22:11:29 +0100 | |
| commit | cfeb161c7ebf93bf6ac39e430fc998dc13abfc66 (patch) | |
| tree | e77411856862dbe91ef7edb475d19e64ff1db18b /src/video_core | |
| parent | gl_rasterizer: Properly scale viewports and scissors (diff) | |
| download | yuzu-cfeb161c7ebf93bf6ac39e430fc998dc13abfc66.tar.gz yuzu-cfeb161c7ebf93bf6ac39e430fc998dc13abfc66.tar.xz yuzu-cfeb161c7ebf93bf6ac39e430fc998dc13abfc66.zip | |
glsl/glasm: Pass and use scaling parameters in shaders
Diffstat (limited to 'src/video_core')
| -rw-r--r-- | src/video_core/renderer_opengl/gl_compute_pipeline.cpp | 23 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | 36 | ||||
| -rw-r--r-- | src/video_core/renderer_opengl/gl_texture_cache.h | 2 |
3 files changed, 40 insertions, 21 deletions
diff --git a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp index a11bd5a02..12093c3c4 100644 --- a/src/video_core/renderer_opengl/gl_compute_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_compute_pipeline.cpp | |||
| @@ -148,14 +148,8 @@ void ComputePipeline::Configure() { | |||
| 148 | const f32 down_factor{is_rescaling ? config_down_factor : 1.0f}; | 148 | const f32 down_factor{is_rescaling ? config_down_factor : 1.0f}; |
| 149 | if (assembly_program.handle != 0) { | 149 | if (assembly_program.handle != 0) { |
| 150 | program_manager.BindComputeAssemblyProgram(assembly_program.handle); | 150 | program_manager.BindComputeAssemblyProgram(assembly_program.handle); |
| 151 | if (info.uses_rescaling_uniform) { | ||
| 152 | glProgramEnvParameter4fARB(GL_COMPUTE_PROGRAM_NV, 0, down_factor, 0.0f, 0.0f, 1.0f); | ||
| 153 | } | ||
| 154 | } else { | 151 | } else { |
| 155 | program_manager.BindComputeProgram(source_program.handle); | 152 | program_manager.BindComputeProgram(source_program.handle); |
| 156 | if (info.uses_rescaling_uniform) { | ||
| 157 | glProgramUniform1f(source_program.handle, 0, down_factor); | ||
| 158 | } | ||
| 159 | } | 153 | } |
| 160 | buffer_cache.UnbindComputeTextureBuffers(); | 154 | buffer_cache.UnbindComputeTextureBuffers(); |
| 161 | size_t texbuf_index{}; | 155 | size_t texbuf_index{}; |
| @@ -187,10 +181,16 @@ void ComputePipeline::Configure() { | |||
| 187 | texture_binding += num_texture_buffers; | 181 | texture_binding += num_texture_buffers; |
| 188 | image_binding += num_image_buffers; | 182 | image_binding += num_image_buffers; |
| 189 | 183 | ||
| 184 | u32 scaling_mask{}; | ||
| 190 | for (const auto& desc : info.texture_descriptors) { | 185 | for (const auto& desc : info.texture_descriptors) { |
| 191 | for (u32 index = 0; index < desc.count; ++index) { | 186 | for (u32 index = 0; index < desc.count; ++index) { |
| 192 | ImageView& image_view{texture_cache.GetImageView((views_it++)->id)}; | 187 | ImageView& image_view{texture_cache.GetImageView((views_it++)->id)}; |
| 193 | textures[texture_binding++] = image_view.Handle(desc.type); | 188 | textures[texture_binding] = image_view.Handle(desc.type); |
| 189 | if (True(texture_cache.GetImage(image_view.image_id).flags & | ||
| 190 | VideoCommon::ImageFlagBits::Rescaled)) { | ||
| 191 | scaling_mask |= 1u << texture_binding; | ||
| 192 | } | ||
| 193 | ++texture_binding; | ||
| 194 | } | 194 | } |
| 195 | } | 195 | } |
| 196 | for (const auto& desc : info.image_descriptors) { | 196 | for (const auto& desc : info.image_descriptors) { |
| @@ -202,6 +202,15 @@ void ComputePipeline::Configure() { | |||
| 202 | images[image_binding++] = image_view.StorageView(desc.type, desc.format); | 202 | images[image_binding++] = image_view.StorageView(desc.type, desc.format); |
| 203 | } | 203 | } |
| 204 | } | 204 | } |
| 205 | if (info.uses_rescaling_uniform) { | ||
| 206 | const f32 float_scaling_mask{Common::BitCast<f32>(scaling_mask)}; | ||
| 207 | if (assembly_program.handle != 0) { | ||
| 208 | glProgramLocalParameter4fARB(GL_COMPUTE_PROGRAM_NV, 0, float_scaling_mask, 0.0f, 0.0f, | ||
| 209 | 0.0f); | ||
| 210 | } else { | ||
| 211 | glProgramUniform4f(source_program.handle, 0, float_scaling_mask, 0.0f, 0.0f, 0.0f); | ||
| 212 | } | ||
| 213 | } | ||
| 205 | if (texture_binding != 0) { | 214 | if (texture_binding != 0) { |
| 206 | ASSERT(texture_binding == sampler_binding); | 215 | ASSERT(texture_binding == sampler_binding); |
| 207 | glBindTextures(0, texture_binding, textures.data()); | 216 | glBindTextures(0, texture_binding, textures.data()); |
diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp index 92fda9af0..01aa2897a 100644 --- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp +++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp | |||
| @@ -444,23 +444,11 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 444 | WaitForBuild(); | 444 | WaitForBuild(); |
| 445 | } | 445 | } |
| 446 | const bool use_assembly{assembly_programs[0].handle != 0}; | 446 | const bool use_assembly{assembly_programs[0].handle != 0}; |
| 447 | const bool is_rescaling{texture_cache.IsRescaling()}; | ||
| 448 | const f32 config_down_factor{Settings::values.resolution_info.down_factor}; | ||
| 449 | const f32 down_factor{is_rescaling ? config_down_factor : 1.0f}; | ||
| 450 | if (use_assembly) { | 447 | if (use_assembly) { |
| 451 | program_manager.BindAssemblyPrograms(assembly_programs, enabled_stages_mask); | 448 | program_manager.BindAssemblyPrograms(assembly_programs, enabled_stages_mask); |
| 452 | } else { | 449 | } else { |
| 453 | program_manager.BindSourcePrograms(source_programs); | 450 | program_manager.BindSourcePrograms(source_programs); |
| 454 | } | 451 | } |
| 455 | for (size_t stage = 0; stage < source_programs.size(); ++stage) { | ||
| 456 | if (stage_infos[stage].uses_rescaling_uniform) { | ||
| 457 | if (use_assembly) { | ||
| 458 | glProgramEnvParameter4fARB(AssemblyStage(stage), 0, down_factor, 0.0f, 0.0f, 1.0f); | ||
| 459 | } else { | ||
| 460 | glProgramUniform1f(source_programs[stage].handle, 0, down_factor); | ||
| 461 | } | ||
| 462 | } | ||
| 463 | } | ||
| 464 | const VideoCommon::ImageViewInOut* views_it{views.data()}; | 452 | const VideoCommon::ImageViewInOut* views_it{views.data()}; |
| 465 | GLsizei texture_binding = 0; | 453 | GLsizei texture_binding = 0; |
| 466 | GLsizei image_binding = 0; | 454 | GLsizei image_binding = 0; |
| @@ -476,11 +464,20 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 476 | views_it += num_texture_buffers[stage]; | 464 | views_it += num_texture_buffers[stage]; |
| 477 | views_it += num_image_buffers[stage]; | 465 | views_it += num_image_buffers[stage]; |
| 478 | 466 | ||
| 467 | u32 scaling_mask{}; | ||
| 468 | u32 stage_texture_binding{}; | ||
| 469 | |||
| 479 | const auto& info{stage_infos[stage]}; | 470 | const auto& info{stage_infos[stage]}; |
| 480 | for (const auto& desc : info.texture_descriptors) { | 471 | for (const auto& desc : info.texture_descriptors) { |
| 481 | for (u32 index = 0; index < desc.count; ++index) { | 472 | for (u32 index = 0; index < desc.count; ++index) { |
| 482 | ImageView& image_view{texture_cache.GetImageView((views_it++)->id)}; | 473 | ImageView& image_view{texture_cache.GetImageView((views_it++)->id)}; |
| 483 | textures[texture_binding++] = image_view.Handle(desc.type); | 474 | textures[texture_binding] = image_view.Handle(desc.type); |
| 475 | if (True(texture_cache.GetImage(image_view.image_id).flags & | ||
| 476 | VideoCommon::ImageFlagBits::Rescaled)) { | ||
| 477 | scaling_mask |= 1u << stage_texture_binding; | ||
| 478 | } | ||
| 479 | ++texture_binding; | ||
| 480 | ++stage_texture_binding; | ||
| 484 | } | 481 | } |
| 485 | } | 482 | } |
| 486 | for (const auto& desc : info.image_descriptors) { | 483 | for (const auto& desc : info.image_descriptors) { |
| @@ -492,6 +489,19 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) { | |||
| 492 | images[image_binding++] = image_view.StorageView(desc.type, desc.format); | 489 | images[image_binding++] = image_view.StorageView(desc.type, desc.format); |
| 493 | } | 490 | } |
| 494 | } | 491 | } |
| 492 | if (info.uses_rescaling_uniform) { | ||
| 493 | const f32 float_scaling_mask{Common::BitCast<f32>(scaling_mask)}; | ||
| 494 | const bool is_rescaling{texture_cache.IsRescaling()}; | ||
| 495 | const f32 config_down_factor{Settings::values.resolution_info.down_factor}; | ||
| 496 | const f32 down_factor{is_rescaling ? config_down_factor : 1.0f}; | ||
| 497 | if (use_assembly) { | ||
| 498 | glProgramLocalParameter4fARB(AssemblyStage(stage), 0, float_scaling_mask, | ||
| 499 | down_factor, 0.0f, 0.0f); | ||
| 500 | } else { | ||
| 501 | glProgramUniform4f(source_programs[stage].handle, 0, float_scaling_mask, | ||
| 502 | down_factor, 0.0f, 0.0f); | ||
| 503 | } | ||
| 504 | } | ||
| 495 | }}; | 505 | }}; |
| 496 | if constexpr (Spec::enabled_stages[0]) { | 506 | if constexpr (Spec::enabled_stages[0]) { |
| 497 | prepare_stage(0); | 507 | prepare_stage(0); |
diff --git a/src/video_core/renderer_opengl/gl_texture_cache.h b/src/video_core/renderer_opengl/gl_texture_cache.h index e76ec522a..28c91b368 100644 --- a/src/video_core/renderer_opengl/gl_texture_cache.h +++ b/src/video_core/renderer_opengl/gl_texture_cache.h | |||
| @@ -210,7 +210,7 @@ private: | |||
| 210 | GLenum gl_internal_format = GL_NONE; | 210 | GLenum gl_internal_format = GL_NONE; |
| 211 | GLenum gl_format = GL_NONE; | 211 | GLenum gl_format = GL_NONE; |
| 212 | GLenum gl_type = GL_NONE; | 212 | GLenum gl_type = GL_NONE; |
| 213 | TextureCacheRuntime* runtime; | 213 | TextureCacheRuntime* runtime{}; |
| 214 | }; | 214 | }; |
| 215 | 215 | ||
| 216 | class ImageView : public VideoCommon::ImageViewBase { | 216 | class ImageView : public VideoCommon::ImageViewBase { |