gl_graphics_program: Fix texture buffer bindings
This commit is contained in:
parent
c721767bcc
commit
80884e3270
@ -2,6 +2,7 @@
|
|||||||
// Licensed under GPLv2 or any later version
|
// Licensed under GPLv2 or any later version
|
||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
|
|
||||||
#include "common/cityhash.h"
|
#include "common/cityhash.h"
|
||||||
@ -14,12 +15,24 @@
|
|||||||
namespace OpenGL {
|
namespace OpenGL {
|
||||||
namespace {
|
namespace {
|
||||||
using Shader::ImageBufferDescriptor;
|
using Shader::ImageBufferDescriptor;
|
||||||
|
using Shader::ImageDescriptor;
|
||||||
|
using Shader::TextureBufferDescriptor;
|
||||||
|
using Shader::TextureDescriptor;
|
||||||
using Tegra::Texture::TexturePair;
|
using Tegra::Texture::TexturePair;
|
||||||
using VideoCommon::ImageId;
|
using VideoCommon::ImageId;
|
||||||
|
|
||||||
constexpr u32 MAX_TEXTURES = 64;
|
constexpr u32 MAX_TEXTURES = 64;
|
||||||
constexpr u32 MAX_IMAGES = 8;
|
constexpr u32 MAX_IMAGES = 8;
|
||||||
|
|
||||||
|
template <typename Range>
|
||||||
|
u32 AccumulateCount(Range&& range) {
|
||||||
|
u32 num{};
|
||||||
|
for (const auto& desc : range) {
|
||||||
|
num += desc.count;
|
||||||
|
}
|
||||||
|
return num;
|
||||||
|
}
|
||||||
|
|
||||||
/// Translates hardware transform feedback indices
|
/// Translates hardware transform feedback indices
|
||||||
/// @param location Hardware location
|
/// @param location Hardware location
|
||||||
/// @return Pair of ARB_transform_feedback3 token stream first and third arguments
|
/// @return Pair of ARB_transform_feedback3 token stream first and third arguments
|
||||||
@ -77,30 +90,25 @@ GraphicsProgram::GraphicsProgram(TextureCache& texture_cache_, BufferCache& buff
|
|||||||
}
|
}
|
||||||
u32 num_textures{};
|
u32 num_textures{};
|
||||||
u32 num_images{};
|
u32 num_images{};
|
||||||
for (size_t stage = 0; stage < base_uniform_bindings.size() - 1; ++stage) {
|
for (size_t stage = 0; stage < base_uniform_bindings.size(); ++stage) {
|
||||||
const auto& info{stage_infos[stage]};
|
const auto& info{stage_infos[stage]};
|
||||||
base_uniform_bindings[stage + 1] = base_uniform_bindings[stage];
|
if (stage < 4) {
|
||||||
base_storage_bindings[stage + 1] = base_storage_bindings[stage];
|
base_uniform_bindings[stage + 1] = base_uniform_bindings[stage];
|
||||||
for (const auto& desc : info.constant_buffer_descriptors) {
|
base_storage_bindings[stage + 1] = base_storage_bindings[stage];
|
||||||
base_uniform_bindings[stage + 1] += desc.count;
|
|
||||||
}
|
base_uniform_bindings[stage + 1] += AccumulateCount(info.constant_buffer_descriptors);
|
||||||
for (const auto& desc : info.storage_buffers_descriptors) {
|
base_storage_bindings[stage + 1] += AccumulateCount(info.storage_buffers_descriptors);
|
||||||
base_storage_bindings[stage + 1] += desc.count;
|
|
||||||
}
|
|
||||||
for (const auto& desc : info.texture_buffer_descriptors) {
|
|
||||||
num_texture_buffers[stage] += desc.count;
|
|
||||||
num_textures += desc.count;
|
|
||||||
}
|
|
||||||
for (const auto& desc : info.image_buffer_descriptors) {
|
|
||||||
num_image_buffers[stage] += desc.count;
|
|
||||||
num_images += desc.count;
|
|
||||||
}
|
|
||||||
for (const auto& desc : info.texture_descriptors) {
|
|
||||||
num_textures += desc.count;
|
|
||||||
}
|
|
||||||
for (const auto& desc : info.image_descriptors) {
|
|
||||||
num_images += desc.count;
|
|
||||||
}
|
}
|
||||||
|
const u32 num_tex_buffer_bindings{AccumulateCount(info.texture_buffer_descriptors)};
|
||||||
|
num_texture_buffers[stage] += num_tex_buffer_bindings;
|
||||||
|
num_textures += num_tex_buffer_bindings;
|
||||||
|
|
||||||
|
const u32 num_img_buffers_bindings{AccumulateCount(info.image_buffer_descriptors)};
|
||||||
|
num_image_buffers[stage] += num_img_buffers_bindings;
|
||||||
|
num_images += num_img_buffers_bindings;
|
||||||
|
|
||||||
|
num_textures += AccumulateCount(info.texture_descriptors);
|
||||||
|
num_images += AccumulateCount(info.image_descriptors);
|
||||||
}
|
}
|
||||||
ASSERT(num_textures <= MAX_TEXTURES);
|
ASSERT(num_textures <= MAX_TEXTURES);
|
||||||
ASSERT(num_images <= MAX_IMAGES);
|
ASSERT(num_images <= MAX_IMAGES);
|
||||||
@ -151,8 +159,8 @@ void GraphicsProgram::Configure(bool is_indexed) {
|
|||||||
const u32 index_offset{index << desc.size_shift};
|
const u32 index_offset{index << desc.size_shift};
|
||||||
const u32 offset{desc.cbuf_offset + index_offset};
|
const u32 offset{desc.cbuf_offset + index_offset};
|
||||||
const GPUVAddr addr{cbufs[desc.cbuf_index].address + offset};
|
const GPUVAddr addr{cbufs[desc.cbuf_index].address + offset};
|
||||||
if constexpr (std::is_same_v<decltype(desc), const Shader::TextureDescriptor&> ||
|
if constexpr (std::is_same_v<decltype(desc), const TextureDescriptor&> ||
|
||||||
std::is_same_v<decltype(desc), const Shader::TextureBufferDescriptor&>) {
|
std::is_same_v<decltype(desc), const TextureBufferDescriptor&>) {
|
||||||
if (desc.has_secondary) {
|
if (desc.has_secondary) {
|
||||||
ASSERT(cbufs[desc.secondary_cbuf_index].enabled);
|
ASSERT(cbufs[desc.secondary_cbuf_index].enabled);
|
||||||
const u32 second_offset{desc.secondary_cbuf_offset + index_offset};
|
const u32 second_offset{desc.secondary_cbuf_offset + index_offset};
|
||||||
@ -297,6 +305,9 @@ void GraphicsProgram::Configure(bool is_indexed) {
|
|||||||
texture_binding += num_texture_buffers[stage];
|
texture_binding += num_texture_buffers[stage];
|
||||||
image_binding += num_image_buffers[stage];
|
image_binding += num_image_buffers[stage];
|
||||||
|
|
||||||
|
views_it += num_texture_buffers[stage];
|
||||||
|
views_it += num_image_buffers[stage];
|
||||||
|
|
||||||
const auto& info{stage_infos[stage]};
|
const auto& info{stage_infos[stage]};
|
||||||
for (const auto& desc : info.texture_descriptors) {
|
for (const auto& desc : info.texture_descriptors) {
|
||||||
for (u32 index = 0; index < desc.count; ++index) {
|
for (u32 index = 0; index < desc.count; ++index) {
|
||||||
|
Loading…
Reference in New Issue
Block a user