diff options
author | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-07-18 02:50:21 +0200 |
---|---|---|
committer | ReinUsesLisp <reinuseslisp@airmail.cc> | 2019-09-06 01:35:51 +0200 |
commit | 80ec2feee8731d661bc999c9f057159ec6286043 (patch) | |
tree | c4d3aaed481e729614c732a46e3f930dc4f0dd4f /src/video_core/renderer_opengl/gl_rasterizer.cpp | |
parent | gl_rasterizer: Minor code changes (diff) | |
download | yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar.gz yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar.bz2 yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar.lz yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar.xz yuzu-80ec2feee8731d661bc999c9f057159ec6286043.tar.zst yuzu-80ec2feee8731d661bc999c9f057159ec6286043.zip |
Diffstat (limited to 'src/video_core/renderer_opengl/gl_rasterizer.cpp')
-rw-r--r-- | src/video_core/renderer_opengl/gl_rasterizer.cpp | 36 |
1 files changed, 33 insertions, 3 deletions
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp index 5454bacb0..fd4753af7 100644 --- a/src/video_core/renderer_opengl/gl_rasterizer.cpp +++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp @@ -801,9 +801,11 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { } auto kernel = shader_cache.GetComputeKernel(code_addr); + ProgramVariant variant; + variant.texture_buffer_usage = SetupComputeTextures(kernel); SetupComputeImages(kernel); - const auto [program, next_bindings] = kernel->GetProgramHandle({}); + const auto [program, next_bindings] = kernel->GetProgramHandle(variant); state.draw.shader_program = program; state.draw.program_pipeline = 0; @@ -818,8 +820,6 @@ void RasterizerOpenGL::DispatchCompute(GPUVAddr code_addr) { SetupComputeConstBuffers(kernel); SetupComputeGlobalMemory(kernel); - // TODO(Rodrigo): Bind images and samplers - buffer_cache.Unmap(); bind_ubo_pushbuffer.Bind(); @@ -1016,6 +1016,36 @@ TextureBufferUsage RasterizerOpenGL::SetupDrawTextures(Maxwell::ShaderStage stag return texture_buffer_usage; } +TextureBufferUsage RasterizerOpenGL::SetupComputeTextures(const Shader& kernel) { + MICROPROFILE_SCOPE(OpenGL_Texture); + const auto& compute = system.GPU().KeplerCompute(); + const auto& entries = kernel->GetShaderEntries().samplers; + + ASSERT_MSG(entries.size() <= std::size(state.textures), + "Exceeded the number of active textures."); + + TextureBufferUsage texture_buffer_usage{0}; + + for (u32 bindpoint = 0; bindpoint < entries.size(); ++bindpoint) { + const auto& entry = entries[bindpoint]; + const auto texture = [&]() { + if (!entry.IsBindless()) { + return compute.GetTexture(entry.GetOffset()); + } + const auto cbuf = entry.GetBindlessCBuf(); + Tegra::Texture::TextureHandle tex_handle; + tex_handle.raw = compute.AccessConstBuffer32(cbuf.first, cbuf.second); + return compute.GetTextureInfo(tex_handle, entry.GetOffset()); + }(); + + if (SetupTexture(bindpoint, texture, entry)) { + texture_buffer_usage.set(bindpoint); + } + } + + return texture_buffer_usage; +} + bool RasterizerOpenGL::SetupTexture(u32 binding, const Tegra::Texture::FullTextureInfo& texture, const GLShader::SamplerEntry& entry) { state.samplers[binding] = sampler_cache.GetSampler(texture.tsc); |