Browse Source

fix openg

lizzie/unity-build
lizzie 1 week ago
parent
commit
8cf1302a9f
  1. 10
      src/video_core/renderer_opengl/gl_buffer_cache.cpp
  2. 18
      src/video_core/renderer_opengl/gl_compute_pipeline.cpp
  3. 18
      src/video_core/renderer_opengl/gl_graphics_pipeline.cpp
  4. 5
      src/video_core/renderer_opengl/gl_rasterizer.h
  5. 38
      src/video_core/renderer_opengl/gl_texture_cache.cpp
  6. 2
      src/video_core/renderer_vulkan/vk_texture_cache.cpp

10
src/video_core/renderer_opengl/gl_buffer_cache.cpp

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2018 yuzu Emulator Project
@ -12,18 +12,12 @@
#include "video_core/renderer_opengl/gl_buffer_cache.h" #include "video_core/renderer_opengl/gl_buffer_cache.h"
#include "video_core/renderer_opengl/gl_device.h" #include "video_core/renderer_opengl/gl_device.h"
#include "video_core/renderer_opengl/maxwell_to_gl.h" #include "video_core/renderer_opengl/maxwell_to_gl.h"
#include "video_core/renderer_opengl/gl_rasterizer.h"
namespace OpenGL { namespace OpenGL {
namespace { namespace {
using VideoCore::Surface::PixelFormat; using VideoCore::Surface::PixelFormat;
struct BindlessSSBO {
GLuint64EXT address;
GLsizei length;
GLsizei padding;
};
static_assert(sizeof(BindlessSSBO) == sizeof(GLuint) * 4);
constexpr std::array PROGRAM_LUT{ constexpr std::array PROGRAM_LUT{
GL_VERTEX_PROGRAM_NV, GL_TESS_CONTROL_PROGRAM_NV, GL_TESS_EVALUATION_PROGRAM_NV, GL_VERTEX_PROGRAM_NV, GL_TESS_CONTROL_PROGRAM_NV, GL_TESS_EVALUATION_PROGRAM_NV,
GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_NV, GL_GEOMETRY_PROGRAM_NV, GL_FRAGMENT_PROGRAM_NV,

18
src/video_core/renderer_opengl/gl_compute_pipeline.cpp

@ -19,8 +19,8 @@ using Shader::ImageBufferDescriptor;
using Tegra::Texture::TexturePair; using Tegra::Texture::TexturePair;
using VideoCommon::ImageId; using VideoCommon::ImageId;
constexpr u32 MAX_TEXTURES = 64;
constexpr u32 MAX_IMAGES = 16;
constexpr u32 MAX_COMPUTE_TEXTURES = 64;
constexpr u32 MAX_COMPUTE_IMAGES = 16;
size_t ComputePipelineKey::Hash() const noexcept { size_t ComputePipelineKey::Hash() const noexcept {
return static_cast<size_t>( return static_cast<size_t>(
@ -56,10 +56,10 @@ ComputePipeline::ComputePipeline(const Device& device, TextureCache& texture_cac
num_image_buffers = Shader::NumDescriptors(info.image_buffer_descriptors); num_image_buffers = Shader::NumDescriptors(info.image_buffer_descriptors);
const u32 num_textures{num_texture_buffers + Shader::NumDescriptors(info.texture_descriptors)}; const u32 num_textures{num_texture_buffers + Shader::NumDescriptors(info.texture_descriptors)};
ASSERT(num_textures <= MAX_TEXTURES);
ASSERT(num_textures <= MAX_COMPUTE_TEXTURES);
const u32 num_images{num_image_buffers + Shader::NumDescriptors(info.image_descriptors)}; const u32 num_images{num_image_buffers + Shader::NumDescriptors(info.image_descriptors)};
ASSERT(num_images <= MAX_IMAGES);
ASSERT(num_images <= MAX_COMPUTE_IMAGES);
const bool is_glasm{assembly_program.handle != 0}; const bool is_glasm{assembly_program.handle != 0};
const u32 num_storage_buffers{Shader::NumDescriptors(info.storage_buffers_descriptors)}; const u32 num_storage_buffers{Shader::NumDescriptors(info.storage_buffers_descriptors)};
@ -92,11 +92,11 @@ void ComputePipeline::Configure() {
} }
texture_cache.SynchronizeComputeDescriptors(); texture_cache.SynchronizeComputeDescriptors();
boost::container::static_vector<VideoCommon::ImageViewInOut, MAX_TEXTURES + MAX_IMAGES> views;
boost::container::static_vector<VideoCommon::SamplerId, MAX_TEXTURES> samplers;
std::array<GLuint, MAX_TEXTURES> gl_samplers;
std::array<GLuint, MAX_TEXTURES> textures;
std::array<GLuint, MAX_IMAGES> images;
boost::container::static_vector<VideoCommon::ImageViewInOut, MAX_COMPUTE_TEXTURES + MAX_COMPUTE_IMAGES> views;
boost::container::static_vector<VideoCommon::SamplerId, MAX_COMPUTE_TEXTURES> samplers;
std::array<GLuint, MAX_COMPUTE_TEXTURES> gl_samplers;
std::array<GLuint, MAX_COMPUTE_TEXTURES> textures;
std::array<GLuint, MAX_COMPUTE_IMAGES> images;
GLsizei sampler_binding{}; GLsizei sampler_binding{};
GLsizei texture_binding{}; GLsizei texture_binding{};
GLsizei image_binding{}; GLsizei image_binding{};

18
src/video_core/renderer_opengl/gl_graphics_pipeline.cpp

@ -36,8 +36,8 @@ 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_IMAGES = 8;
constexpr u32 MAX_GRAPHICS_TEXTURES = 64;
constexpr u32 MAX_GRAPHICS_IMAGES = 8;
GLenum Stage(size_t stage_index) { GLenum Stage(size_t stage_index) {
switch (stage_index) { switch (stage_index) {
@ -221,8 +221,8 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
info.storage_buffers_descriptors, [](const auto& desc) { return desc.is_written; }); info.storage_buffers_descriptors, [](const auto& desc) { return desc.is_written; });
uses_local_memory |= info.uses_local_memory; uses_local_memory |= info.uses_local_memory;
} }
ASSERT(num_textures <= MAX_TEXTURES);
ASSERT(num_images <= MAX_IMAGES);
ASSERT(num_textures <= MAX_GRAPHICS_TEXTURES);
ASSERT(num_images <= MAX_GRAPHICS_IMAGES);
const auto backend = ::Settings::values.renderer_backend.GetValue(); const auto backend = ::Settings::values.renderer_backend.GetValue();
const bool assembly_shaders = backend == Settings::RendererBackend::OpenGL_GLASM; const bool assembly_shaders = backend == Settings::RendererBackend::OpenGL_GLASM;
@ -278,8 +278,8 @@ GraphicsPipeline::GraphicsPipeline(const Device& device, TextureCache& texture_c
template <typename Spec> template <typename Spec>
bool GraphicsPipeline::ConfigureImpl(bool is_indexed) { bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
std::array<VideoCommon::ImageViewInOut, MAX_TEXTURES + MAX_IMAGES> views;
std::array<VideoCommon::SamplerId, MAX_TEXTURES> samplers;
std::array<VideoCommon::ImageViewInOut, MAX_GRAPHICS_TEXTURES + MAX_GRAPHICS_IMAGES> views;
std::array<VideoCommon::SamplerId, MAX_GRAPHICS_TEXTURES> samplers;
size_t views_index{}; size_t views_index{};
size_t samplers_index{}; size_t samplers_index{};
@ -452,9 +452,9 @@ bool GraphicsPipeline::ConfigureImpl(bool is_indexed) {
GLsizei texture_binding = 0; GLsizei texture_binding = 0;
GLsizei image_binding = 0; GLsizei image_binding = 0;
GLsizei sampler_binding{}; GLsizei sampler_binding{};
std::array<GLuint, MAX_TEXTURES> textures;
std::array<GLuint, MAX_IMAGES> images;
std::array<GLuint, MAX_TEXTURES> gl_samplers;
std::array<GLuint, MAX_GRAPHICS_TEXTURES> textures;
std::array<GLuint, MAX_GRAPHICS_IMAGES> images;
std::array<GLuint, MAX_GRAPHICS_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);

5
src/video_core/renderer_opengl/gl_rasterizer.h

@ -1,3 +1,6 @@
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: 2015 Citra Emulator Project // SPDX-FileCopyrightText: 2015 Citra Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later // SPDX-License-Identifier: GPL-2.0-or-later
@ -256,7 +259,7 @@ private:
BlitImageHelper blit_image; BlitImageHelper blit_image;
boost::container::static_vector<u32, MAX_IMAGE_VIEWS> image_view_indices; boost::container::static_vector<u32, MAX_IMAGE_VIEWS> image_view_indices;
std::array<ImageViewId, MAX_IMAGE_VIEWS> image_view_ids;
std::array<VideoCommon::ImageViewId, MAX_IMAGE_VIEWS> image_view_ids;
boost::container::static_vector<GLuint, MAX_TEXTURES> sampler_handles; boost::container::static_vector<GLuint, MAX_TEXTURES> sampler_handles;
std::array<GLuint, MAX_TEXTURES> texture_handles{}; std::array<GLuint, MAX_TEXTURES> texture_handles{};
std::array<GLuint, MAX_IMAGES> image_handles{}; std::array<GLuint, MAX_IMAGES> image_handles{};

38
src/video_core/renderer_opengl/gl_texture_cache.cpp

@ -1,4 +1,4 @@
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
// SPDX-FileCopyrightText: Copyright 2026 Eden Emulator Project
// SPDX-License-Identifier: GPL-3.0-or-later // SPDX-License-Identifier: GPL-3.0-or-later
// SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project // SPDX-FileCopyrightText: Copyright 2019 yuzu Emulator Project
@ -1103,7 +1103,7 @@ bool Image::ScaleDown(bool ignore) {
} }
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info,
ImageId image_id_, Image& image, const SlotVector<Image>&)
ImageId image_id_, Image& image, const Common::SlotVector<Image>&)
: VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr}, : VideoCommon::ImageViewBase{info, image.info, image_id_, image.gpu_addr},
views{runtime.null_image_views} { views{runtime.null_image_views} {
const Device& device = runtime.device; const Device& device = runtime.device;
@ -1130,18 +1130,18 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
swizzle[3] = info.w_source; swizzle[3] = info.w_source;
} }
switch (info.type) { switch (info.type) {
case ImageViewType::e1DArray:
case VideoCommon::ImageViewType::e1DArray:
flat_range.extent.layers = 1; flat_range.extent.layers = 1;
[[fallthrough]]; [[fallthrough]];
case ImageViewType::e1D:
case VideoCommon::ImageViewType::e1D:
SetupView(Shader::TextureType::Color1D); SetupView(Shader::TextureType::Color1D);
SetupView(Shader::TextureType::ColorArray1D); SetupView(Shader::TextureType::ColorArray1D);
break; break;
case ImageViewType::e2DArray:
case VideoCommon::ImageViewType::e2DArray:
flat_range.extent.layers = 1; flat_range.extent.layers = 1;
[[fallthrough]]; [[fallthrough]];
case ImageViewType::e2D:
case ImageViewType::Rect:
case VideoCommon::ImageViewType::e2D:
case VideoCommon::ImageViewType::Rect:
if (True(flags & VideoCommon::ImageViewFlagBits::Slice)) { if (True(flags & VideoCommon::ImageViewFlagBits::Slice)) {
// 2D and 2D array views on a 3D textures are used exclusively for render targets // 2D and 2D array views on a 3D textures are used exclusively for render targets
ASSERT(info.range.extent.levels == 1); ASSERT(info.range.extent.levels == 1);
@ -1157,41 +1157,41 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
SetupView(Shader::TextureType::ColorArray2D); SetupView(Shader::TextureType::ColorArray2D);
} }
break; break;
case ImageViewType::e3D:
case VideoCommon::ImageViewType::e3D:
SetupView(Shader::TextureType::Color3D); SetupView(Shader::TextureType::Color3D);
break; break;
case ImageViewType::CubeArray:
case VideoCommon::ImageViewType::CubeArray:
flat_range.extent.layers = 6; flat_range.extent.layers = 6;
[[fallthrough]]; [[fallthrough]];
case ImageViewType::Cube:
case VideoCommon::ImageViewType::Cube:
SetupView(Shader::TextureType::ColorCube); SetupView(Shader::TextureType::ColorCube);
SetupView(Shader::TextureType::ColorArrayCube); SetupView(Shader::TextureType::ColorArrayCube);
break; break;
case ImageViewType::Buffer:
case VideoCommon::ImageViewType::Buffer:
ASSERT(false); ASSERT(false);
break; break;
} }
switch (info.type) { switch (info.type) {
case ImageViewType::e1D:
case VideoCommon::ImageViewType::e1D:
default_handle = Handle(Shader::TextureType::Color1D); default_handle = Handle(Shader::TextureType::Color1D);
break; break;
case ImageViewType::e1DArray:
case VideoCommon::ImageViewType::e1DArray:
default_handle = Handle(Shader::TextureType::ColorArray1D); default_handle = Handle(Shader::TextureType::ColorArray1D);
break; break;
case ImageViewType::e2D:
case ImageViewType::Rect:
case VideoCommon::ImageViewType::e2D:
case VideoCommon::ImageViewType::Rect:
default_handle = Handle(Shader::TextureType::Color2D); default_handle = Handle(Shader::TextureType::Color2D);
break; break;
case ImageViewType::e2DArray:
case VideoCommon::ImageViewType::e2DArray:
default_handle = Handle(Shader::TextureType::ColorArray2D); default_handle = Handle(Shader::TextureType::ColorArray2D);
break; break;
case ImageViewType::e3D:
case VideoCommon::ImageViewType::e3D:
default_handle = Handle(Shader::TextureType::Color3D); default_handle = Handle(Shader::TextureType::Color3D);
break; break;
case ImageViewType::Cube:
case VideoCommon::ImageViewType::Cube:
default_handle = Handle(Shader::TextureType::ColorCube); default_handle = Handle(Shader::TextureType::ColorCube);
break; break;
case ImageViewType::CubeArray:
case VideoCommon::ImageViewType::CubeArray:
default_handle = Handle(Shader::TextureType::ColorArrayCube); default_handle = Handle(Shader::TextureType::ColorArrayCube);
break; break;
default: default:

2
src/video_core/renderer_vulkan/vk_texture_cache.cpp

@ -2178,7 +2178,7 @@ ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewI
} }
} }
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageId image_id_, Image& image, const SlotVector<Image>& slot_imgs)
ImageView::ImageView(TextureCacheRuntime& runtime, const VideoCommon::ImageViewInfo& info, ImageId image_id_, Image& image, const Common::SlotVector<Image>& slot_imgs)
: ImageView{runtime, info, image_id_, image} : ImageView{runtime, info, image_id_, image}
{ {
slot_images = &slot_imgs; slot_images = &slot_imgs;

Loading…
Cancel
Save