summaryrefslogtreecommitdiffstats
path: root/src/video_core
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/video_core/renderer_opengl/gl_buffer_cache.cpp15
-rw-r--r--src/video_core/renderer_opengl/gl_graphics_pipeline.cpp4
-rw-r--r--src/video_core/renderer_opengl/gl_rasterizer.cpp10
-rw-r--r--src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp4
-rw-r--r--src/video_core/renderer_vulkan/vk_rasterizer.cpp10
-rw-r--r--src/video_core/shader_environment.cpp89
-rw-r--r--src/video_core/shader_environment.h12
-rw-r--r--src/video_core/texture_cache/util.cpp1
8 files changed, 109 insertions, 36 deletions
diff --git a/src/video_core/renderer_opengl/gl_buffer_cache.cpp b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
index 08f4d69ab..6af4ae793 100644
--- a/src/video_core/renderer_opengl/gl_buffer_cache.cpp
+++ b/src/video_core/renderer_opengl/gl_buffer_cache.cpp
@@ -29,17 +29,17 @@ constexpr std::array PROGRAM_LUT{
[[nodiscard]] GLenum GetTextureBufferFormat(GLenum gl_format) {
switch (gl_format) {
case GL_RGBA8_SNORM:
- return GL_RGBA8;
+ return GL_RGBA8I;
case GL_R8_SNORM:
- return GL_R8;
+ return GL_R8I;
case GL_RGBA16_SNORM:
- return GL_RGBA16;
+ return GL_RGBA16I;
case GL_R16_SNORM:
- return GL_R16;
+ return GL_R16I;
case GL_RG16_SNORM:
- return GL_RG16;
+ return GL_RG16I;
case GL_RG8_SNORM:
- return GL_RG8;
+ return GL_RG8I;
default:
return gl_format;
}
@@ -96,9 +96,6 @@ GLuint Buffer::View(u32 offset, u32 size, PixelFormat format) {
texture.Create(GL_TEXTURE_BUFFER);
const GLenum gl_format{MaxwellToGL::GetFormatTuple(format).internal_format};
const GLenum texture_format{GetTextureBufferFormat(gl_format)};
- if (texture_format != gl_format) {
- LOG_WARNING(Render_OpenGL, "Emulating SNORM texture buffer with UNORM.");
- }
glTextureBufferRange(texture.handle, texture_format, buffer.handle, offset, size);
views.push_back({
.offset = offset,
diff --git a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp
index daceb05f4..c115dabe1 100644
--- a/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp
+++ b/src/video_core/renderer_opengl/gl_graphics_pipeline.cpp
@@ -504,8 +504,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
}
}
if (info.uses_render_area) {
- const auto render_area_width(static_cast<GLfloat>(regs.render_area.width));
- const auto render_area_height(static_cast<GLfloat>(regs.render_area.height));
+ const auto render_area_width(static_cast<GLfloat>(regs.surface_clip.width));
+ const auto render_area_height(static_cast<GLfloat>(regs.surface_clip.height));
if (use_assembly) {
glProgramLocalParameter4fARB(AssemblyStage(stage), 1, render_area_width,
render_area_height, 0.0f, 0.0f);
diff --git a/src/video_core/renderer_opengl/gl_rasterizer.cpp b/src/video_core/renderer_opengl/gl_rasterizer.cpp
index 79d7908d4..72e314d39 100644
--- a/src/video_core/renderer_opengl/gl_rasterizer.cpp
+++ b/src/video_core/renderer_opengl/gl_rasterizer.cpp
@@ -618,11 +618,11 @@ void RasterizerOpenGL::SyncViewport() {
}
flags[Dirty::Viewport0 + index] = false;
- if (!regs.viewport_transform_enabled) {
- const auto x = static_cast<GLfloat>(regs.render_area.x);
- const auto y = static_cast<GLfloat>(regs.render_area.y);
- const auto width = static_cast<GLfloat>(regs.render_area.width);
- const auto height = static_cast<GLfloat>(regs.render_area.height);
+ if (!regs.viewport_scale_offset_enbled) {
+ const auto x = static_cast<GLfloat>(regs.surface_clip.x);
+ const auto y = static_cast<GLfloat>(regs.surface_clip.y);
+ const auto width = static_cast<GLfloat>(regs.surface_clip.width);
+ const auto height = static_cast<GLfloat>(regs.surface_clip.height);
glViewportIndexedf(static_cast<GLuint>(index), x, y, width != 0.0f ? width : 1.0f,
height != 0.0f ? height : 1.0f);
continue;
diff --git a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
index b4372a839..81b6c372d 100644
--- a/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
+++ b/src/video_core/renderer_vulkan/vk_graphics_pipeline.cpp
@@ -444,8 +444,8 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
const auto& info{stage_infos[0]};
if (info.uses_render_area) {
render_area.uses_render_area = true;
- render_area.words = {static_cast<float>(regs.render_area.width),
- static_cast<float>(regs.render_area.height)};
+ render_area.words = {static_cast<float>(regs.surface_clip.width),
+ static_cast<float>(regs.surface_clip.height)};
}
}};
if constexpr (Spec::enabled_stages[0]) {
diff --git a/src/video_core/renderer_vulkan/vk_rasterizer.cpp b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
index 5af3c930b..f79fa8313 100644
--- a/src/video_core/renderer_vulkan/vk_rasterizer.cpp
+++ b/src/video_core/renderer_vulkan/vk_rasterizer.cpp
@@ -683,11 +683,11 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg
if (!state_tracker.TouchViewports()) {
return;
}
- if (!regs.viewport_transform_enabled) {
- const auto x = static_cast<float>(regs.render_area.x);
- const auto y = static_cast<float>(regs.render_area.y);
- const auto width = static_cast<float>(regs.render_area.width);
- const auto height = static_cast<float>(regs.render_area.height);
+ if (!regs.viewport_scale_offset_enbled) {
+ const auto x = static_cast<float>(regs.surface_clip.x);
+ const auto y = static_cast<float>(regs.surface_clip.y);
+ const auto width = static_cast<float>(regs.surface_clip.width);
+ const auto height = static_cast<float>(regs.surface_clip.height);
VkViewport viewport{
.x = x,
.y = y,
diff --git a/src/video_core/shader_environment.cpp b/src/video_core/shader_environment.cpp
index 63bcf9337..37bb76b72 100644
--- a/src/video_core/shader_environment.cpp
+++ b/src/video_core/shader_environment.cpp
@@ -19,6 +19,7 @@
#include "video_core/engines/kepler_compute.h"
#include "video_core/memory_manager.h"
#include "video_core/shader_environment.h"
+#include "video_core/texture_cache/format_lookup_table.h"
#include "video_core/textures/texture.h"
namespace VideoCommon {
@@ -33,7 +34,7 @@ static u64 MakeCbufKey(u32 index, u32 offset) {
return (static_cast<u64>(index) << 32) | offset;
}
-static Shader::TextureType ConvertType(const Tegra::Texture::TICEntry& entry) {
+static Shader::TextureType ConvertTextureType(const Tegra::Texture::TICEntry& entry) {
switch (entry.texture_type) {
case Tegra::Texture::TextureType::Texture1D:
return Shader::TextureType::Color1D;
@@ -59,6 +60,26 @@ static Shader::TextureType ConvertType(const Tegra::Texture::TICEntry& entry) {
}
}
+static Shader::TexturePixelFormat ConvertTexturePixelFormat(const Tegra::Texture::TICEntry& entry) {
+ switch (PixelFormatFromTextureInfo(entry.format, entry.r_type, entry.g_type, entry.b_type,
+ entry.a_type, entry.srgb_conversion)) {
+ case VideoCore::Surface::PixelFormat::A8B8G8R8_SNORM:
+ return Shader::TexturePixelFormat::A8B8G8R8_SNORM;
+ case VideoCore::Surface::PixelFormat::R8_SNORM:
+ return Shader::TexturePixelFormat::R8_SNORM;
+ case VideoCore::Surface::PixelFormat::R8G8_SNORM:
+ return Shader::TexturePixelFormat::R8G8_SNORM;
+ case VideoCore::Surface::PixelFormat::R16G16B16A16_SNORM:
+ return Shader::TexturePixelFormat::R16G16B16A16_SNORM;
+ case VideoCore::Surface::PixelFormat::R16G16_SNORM:
+ return Shader::TexturePixelFormat::R16G16_SNORM;
+ case VideoCore::Surface::PixelFormat::R16_SNORM:
+ return Shader::TexturePixelFormat::R16_SNORM;
+ default:
+ return Shader::TexturePixelFormat::OTHER;
+ }
+}
+
static std::string_view StageToPrefix(Shader::Stage stage) {
switch (stage) {
case Shader::Stage::VertexB:
@@ -178,10 +199,13 @@ void GenericEnvironment::Dump(u64 hash) {
void GenericEnvironment::Serialize(std::ofstream& file) const {
const u64 code_size{static_cast<u64>(CachedSize())};
const u64 num_texture_types{static_cast<u64>(texture_types.size())};
+ const u64 num_texture_pixel_formats{static_cast<u64>(texture_pixel_formats.size())};
const u64 num_cbuf_values{static_cast<u64>(cbuf_values.size())};
file.write(reinterpret_cast<const char*>(&code_size), sizeof(code_size))
.write(reinterpret_cast<const char*>(&num_texture_types), sizeof(num_texture_types))
+ .write(reinterpret_cast<const char*>(&num_texture_pixel_formats),
+ sizeof(num_texture_pixel_formats))
.write(reinterpret_cast<const char*>(&num_cbuf_values), sizeof(num_cbuf_values))
.write(reinterpret_cast<const char*>(&local_memory_size), sizeof(local_memory_size))
.write(reinterpret_cast<const char*>(&texture_bound), sizeof(texture_bound))
@@ -196,6 +220,10 @@ void GenericEnvironment::Serialize(std::ofstream& file) const {
file.write(reinterpret_cast<const char*>(&key), sizeof(key))
.write(reinterpret_cast<const char*>(&type), sizeof(type));
}
+ for (const auto& [key, format] : texture_pixel_formats) {
+ file.write(reinterpret_cast<const char*>(&key), sizeof(key))
+ .write(reinterpret_cast<const char*>(&format), sizeof(format));
+ }
for (const auto& [key, type] : cbuf_values) {
file.write(reinterpret_cast<const char*>(&key), sizeof(key))
.write(reinterpret_cast<const char*>(&type), sizeof(type));
@@ -239,15 +267,13 @@ std::optional<u64> GenericEnvironment::TryFindSize() {
return std::nullopt;
}
-Shader::TextureType GenericEnvironment::ReadTextureTypeImpl(GPUVAddr tic_addr, u32 tic_limit,
- bool via_header_index, u32 raw) {
+Tegra::Texture::TICEntry GenericEnvironment::ReadTextureInfo(GPUVAddr tic_addr, u32 tic_limit,
+ bool via_header_index, u32 raw) {
const auto handle{Tegra::Texture::TexturePair(raw, via_header_index)};
const GPUVAddr descriptor_addr{tic_addr + handle.first * sizeof(Tegra::Texture::TICEntry)};
Tegra::Texture::TICEntry entry;
gpu_memory->ReadBlock(descriptor_addr, &entry, sizeof(entry));
- const Shader::TextureType result{ConvertType(entry)};
- texture_types.emplace(raw, result);
- return result;
+ return entry;
}
GraphicsEnvironment::GraphicsEnvironment(Tegra::Engines::Maxwell3D& maxwell3d_,
@@ -307,13 +333,26 @@ u32 GraphicsEnvironment::ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) {
Shader::TextureType GraphicsEnvironment::ReadTextureType(u32 handle) {
const auto& regs{maxwell3d->regs};
const bool via_header_index{regs.sampler_binding == Maxwell::SamplerBinding::ViaHeaderBinding};
- return ReadTextureTypeImpl(regs.tex_header.Address(), regs.tex_header.limit, via_header_index,
- handle);
+ auto entry =
+ ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
+ const Shader::TextureType result{ConvertTextureType(entry)};
+ texture_types.emplace(handle, result);
+ return result;
+}
+
+Shader::TexturePixelFormat GraphicsEnvironment::ReadTexturePixelFormat(u32 handle) {
+ const auto& regs{maxwell3d->regs};
+ const bool via_header_index{regs.sampler_binding == Maxwell::SamplerBinding::ViaHeaderBinding};
+ auto entry =
+ ReadTextureInfo(regs.tex_header.Address(), regs.tex_header.limit, via_header_index, handle);
+ const Shader::TexturePixelFormat result(ConvertTexturePixelFormat(entry));
+ texture_pixel_formats.emplace(handle, result);
+ return result;
}
u32 GraphicsEnvironment::ReadViewportTransformState() {
const auto& regs{maxwell3d->regs};
- viewport_transform_state = regs.viewport_transform_enabled;
+ viewport_transform_state = regs.viewport_scale_offset_enbled;
return viewport_transform_state;
}
@@ -345,7 +384,19 @@ u32 ComputeEnvironment::ReadCbufValue(u32 cbuf_index, u32 cbuf_offset) {
Shader::TextureType ComputeEnvironment::ReadTextureType(u32 handle) {
const auto& regs{kepler_compute->regs};
const auto& qmd{kepler_compute->launch_description};
- return ReadTextureTypeImpl(regs.tic.Address(), regs.tic.limit, qmd.linked_tsc != 0, handle);
+ auto entry = ReadTextureInfo(regs.tic.Address(), regs.tic.limit, qmd.linked_tsc != 0, handle);
+ const Shader::TextureType result{ConvertTextureType(entry)};
+ texture_types.emplace(handle, result);
+ return result;
+}
+
+Shader::TexturePixelFormat ComputeEnvironment::ReadTexturePixelFormat(u32 handle) {
+ const auto& regs{kepler_compute->regs};
+ const auto& qmd{kepler_compute->launch_description};
+ auto entry = ReadTextureInfo(regs.tic.Address(), regs.tic.limit, qmd.linked_tsc != 0, handle);
+ const Shader::TexturePixelFormat result(ConvertTexturePixelFormat(entry));
+ texture_pixel_formats.emplace(handle, result);
+ return result;
}
u32 ComputeEnvironment::ReadViewportTransformState() {
@@ -355,9 +406,12 @@ u32 ComputeEnvironment::ReadViewportTransformState() {
void FileEnvironment::Deserialize(std::ifstream& file) {
u64 code_size{};
u64 num_texture_types{};
+ u64 num_texture_pixel_formats{};
u64 num_cbuf_values{};
file.read(reinterpret_cast<char*>(&code_size), sizeof(code_size))
.read(reinterpret_cast<char*>(&num_texture_types), sizeof(num_texture_types))
+ .read(reinterpret_cast<char*>(&num_texture_pixel_formats),
+ sizeof(num_texture_pixel_formats))
.read(reinterpret_cast<char*>(&num_cbuf_values), sizeof(num_cbuf_values))
.read(reinterpret_cast<char*>(&local_memory_size), sizeof(local_memory_size))
.read(reinterpret_cast<char*>(&texture_bound), sizeof(texture_bound))
@@ -375,6 +429,13 @@ void FileEnvironment::Deserialize(std::ifstream& file) {
.read(reinterpret_cast<char*>(&type), sizeof(type));
texture_types.emplace(key, type);
}
+ for (size_t i = 0; i < num_texture_pixel_formats; ++i) {
+ u32 key;
+ Shader::TexturePixelFormat format;
+ file.read(reinterpret_cast<char*>(&key), sizeof(key))
+ .read(reinterpret_cast<char*>(&format), sizeof(format));
+ texture_pixel_formats.emplace(key, format);
+ }
for (size_t i = 0; i < num_cbuf_values; ++i) {
u64 key;
u32 value;
@@ -422,6 +483,14 @@ Shader::TextureType FileEnvironment::ReadTextureType(u32 handle) {
return it->second;
}
+Shader::TexturePixelFormat FileEnvironment::ReadTexturePixelFormat(u32 handle) {
+ const auto it{texture_pixel_formats.find(handle)};
+ if (it == texture_pixel_formats.end()) {
+ throw Shader::LogicError("Uncached read texture pixel format");
+ }
+ return it->second;
+}
+
u32 FileEnvironment::ReadViewportTransformState() {
return viewport_transform_state;
}
diff --git a/src/video_core/shader_environment.h b/src/video_core/shader_environment.h
index a05833f38..bb55b029f 100644
--- a/src/video_core/shader_environment.h
+++ b/src/video_core/shader_environment.h
@@ -63,14 +63,15 @@ public:
protected:
std::optional<u64> TryFindSize();
- Shader::TextureType ReadTextureTypeImpl(GPUVAddr tic_addr, u32 tic_limit, bool via_header_index,
- u32 raw);
+ Tegra::Texture::TICEntry ReadTextureInfo(GPUVAddr tic_addr, u32 tic_limit,
+ bool via_header_index, u32 raw);
Tegra::MemoryManager* gpu_memory{};
GPUVAddr program_base{};
std::vector<u64> code;
std::unordered_map<u32, Shader::TextureType> texture_types;
+ std::unordered_map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
std::unordered_map<u64, u32> cbuf_values;
u32 local_memory_size{};
@@ -104,6 +105,8 @@ public:
Shader::TextureType ReadTextureType(u32 handle) override;
+ Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
+
u32 ReadViewportTransformState() override;
private:
@@ -124,6 +127,8 @@ public:
Shader::TextureType ReadTextureType(u32 handle) override;
+ Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
+
u32 ReadViewportTransformState() override;
private:
@@ -149,6 +154,8 @@ public:
[[nodiscard]] Shader::TextureType ReadTextureType(u32 handle) override;
+ [[nodiscard]] Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
+
[[nodiscard]] u32 ReadViewportTransformState() override;
[[nodiscard]] u32 LocalMemorySize() const override;
@@ -164,6 +171,7 @@ public:
private:
std::unique_ptr<u64[]> code;
std::unordered_map<u32, Shader::TextureType> texture_types;
+ std::unordered_map<u32, Shader::TexturePixelFormat> texture_pixel_formats;
std::unordered_map<u64, u32> cbuf_values;
std::array<u32, 3> workgroup_size{};
u32 local_memory_size{};
diff --git a/src/video_core/texture_cache/util.cpp b/src/video_core/texture_cache/util.cpp
index 1223df5a0..e8c908b42 100644
--- a/src/video_core/texture_cache/util.cpp
+++ b/src/video_core/texture_cache/util.cpp
@@ -516,7 +516,6 @@ void SwizzleBlockLinearImage(Tegra::MemoryManager& gpu_memory, GPUVAddr gpu_addr
const u32 num_blocks_per_layer = NumBlocks(level_size, tile_size);
const u32 host_bytes_per_layer = num_blocks_per_layer * bytes_per_block;
- UNIMPLEMENTED_IF(info.tile_width_spacing > 0);
UNIMPLEMENTED_IF(copy.image_offset.x != 0);
UNIMPLEMENTED_IF(copy.image_offset.y != 0);
UNIMPLEMENTED_IF(copy.image_offset.z != 0);