|
|
@ -275,9 +275,9 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
|
|
|
|
template <typename Spec>
|
|
|
|
template <typename Spec>
|
|
|
|
void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
std::array<VideoCommon::ImageViewInOut, MAX_TEXTURES + MAX_IMAGES> views;
|
|
|
|
std::array<VideoCommon::ImageViewInOut, MAX_TEXTURES + MAX_IMAGES> views;
|
|
|
|
std::array<GLuint, MAX_TEXTURES> samplers;
|
|
|
|
std::array<VideoCommon::SamplerId, MAX_TEXTURES> samplers;
|
|
|
|
size_t views_index{};
|
|
|
|
size_t views_index{};
|
|
|
|
GLsizei sampler_binding{};
|
|
|
|
size_t samplers_index{};
|
|
|
|
|
|
|
|
|
|
|
|
texture_cache.SynchronizeGraphicsDescriptors();
|
|
|
|
texture_cache.SynchronizeGraphicsDescriptors();
|
|
|
|
|
|
|
|
|
|
|
@ -337,7 +337,6 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
for (u32 index = 0; index < desc.count; ++index) {
|
|
|
|
for (u32 index = 0; index < desc.count; ++index) {
|
|
|
|
const auto handle{read_handle(desc, index)};
|
|
|
|
const auto handle{read_handle(desc, index)};
|
|
|
|
views[views_index++] = {handle.first};
|
|
|
|
views[views_index++] = {handle.first};
|
|
|
|
samplers[sampler_binding++] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -351,8 +350,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
const auto handle{read_handle(desc, index)};
|
|
|
|
const auto handle{read_handle(desc, index)};
|
|
|
|
views[views_index++] = {handle.first};
|
|
|
|
views[views_index++] = {handle.first};
|
|
|
|
|
|
|
|
|
|
|
|
Sampler* const sampler{texture_cache.GetGraphicsSampler(handle.second)};
|
|
|
|
VideoCommon::SamplerId sampler{texture_cache.GetGraphicsSamplerId(handle.second)};
|
|
|
|
samplers[sampler_binding++] = sampler->Handle();
|
|
|
|
samplers[samplers_index++] = sampler;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if constexpr (Spec::has_images) {
|
|
|
|
if constexpr (Spec::has_images) {
|
|
|
@ -445,10 +444,13 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
program_manager.BindSourcePrograms(source_programs);
|
|
|
|
program_manager.BindSourcePrograms(source_programs);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
const VideoCommon::ImageViewInOut* views_it{views.data()};
|
|
|
|
const VideoCommon::ImageViewInOut* views_it{views.data()};
|
|
|
|
|
|
|
|
const VideoCommon::SamplerId* samplers_it{samplers.data()};
|
|
|
|
GLsizei texture_binding = 0;
|
|
|
|
GLsizei texture_binding = 0;
|
|
|
|
GLsizei image_binding = 0;
|
|
|
|
GLsizei image_binding = 0;
|
|
|
|
|
|
|
|
GLsizei sampler_binding{};
|
|
|
|
std::array<GLuint, MAX_TEXTURES> textures;
|
|
|
|
std::array<GLuint, MAX_TEXTURES> textures;
|
|
|
|
std::array<GLuint, MAX_IMAGES> images;
|
|
|
|
std::array<GLuint, MAX_IMAGES> images;
|
|
|
|
|
|
|
|
std::array<GLuint, MAX_TEXTURES> gl_samplers;
|
|
|
|
const auto prepare_stage{[&](size_t stage) {
|
|
|
|
const auto prepare_stage{[&](size_t stage) {
|
|
|
|
buffer_cache.runtime.SetImagePointers(&textures[texture_binding], &images[image_binding]);
|
|
|
|
buffer_cache.runtime.SetImagePointers(&textures[texture_binding], &images[image_binding]);
|
|
|
|
buffer_cache.BindHostStageBuffers(stage);
|
|
|
|
buffer_cache.BindHostStageBuffers(stage);
|
|
|
@ -465,6 +467,13 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
u32 stage_image_binding{};
|
|
|
|
u32 stage_image_binding{};
|
|
|
|
|
|
|
|
|
|
|
|
const auto& info{stage_infos[stage]};
|
|
|
|
const auto& info{stage_infos[stage]};
|
|
|
|
|
|
|
|
if constexpr (Spec::has_texture_buffers) {
|
|
|
|
|
|
|
|
for (const auto& desc : info.texture_buffer_descriptors) {
|
|
|
|
|
|
|
|
for (u32 index = 0; index < desc.count; ++index) {
|
|
|
|
|
|
|
|
gl_samplers[sampler_binding++] = 0;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
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) {
|
|
|
|
ImageView& image_view{texture_cache.GetImageView((views_it++)->id)};
|
|
|
|
ImageView& image_view{texture_cache.GetImageView((views_it++)->id)};
|
|
|
@ -474,6 +483,12 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
++texture_binding;
|
|
|
|
++texture_binding;
|
|
|
|
++stage_texture_binding;
|
|
|
|
++stage_texture_binding;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const Sampler& sampler{texture_cache.GetSampler(*(samplers_it++))};
|
|
|
|
|
|
|
|
const bool use_fallback_sampler{sampler.HasAddedAnisotropy() &&
|
|
|
|
|
|
|
|
!image_view.SupportsAnisotropy()};
|
|
|
|
|
|
|
|
gl_samplers[sampler_binding++] =
|
|
|
|
|
|
|
|
use_fallback_sampler ? sampler.HandleWithDefaultAnisotropy() : sampler.Handle();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (const auto& desc : info.image_descriptors) {
|
|
|
|
for (const auto& desc : info.image_descriptors) {
|
|
|
@ -534,7 +549,7 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
|
|
|
if (texture_binding != 0) {
|
|
|
|
if (texture_binding != 0) {
|
|
|
|
ASSERT(texture_binding == sampler_binding);
|
|
|
|
ASSERT(texture_binding == sampler_binding);
|
|
|
|
glBindTextures(0, texture_binding, textures.data());
|
|
|
|
glBindTextures(0, texture_binding, textures.data());
|
|
|
|
glBindSamplers(0, sampler_binding, samplers.data());
|
|
|
|
glBindSamplers(0, sampler_binding, gl_samplers.data());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (image_binding != 0) {
|
|
|
|
if (image_binding != 0) {
|
|
|
|
glBindImageTextures(0, image_binding, images.data());
|
|
|
|
glBindImageTextures(0, image_binding, images.data());
|
|
|
|