early-access version 3089
This commit is contained in:
@@ -2970,7 +2970,7 @@ public:
|
||||
CullFace gl_cull_face; ///< 0x1920
|
||||
Viewport::PixelCenter viewport_pixel_center; ///< 0x1924
|
||||
INSERT_PADDING_BYTES_NOINIT(0x4);
|
||||
u32 viewport_scale_offset_enbled; ///< 0x192C
|
||||
u32 viewport_scale_offset_enabled; ///< 0x192C
|
||||
INSERT_PADDING_BYTES_NOINIT(0xC);
|
||||
ViewportClipControl viewport_clip_control; ///< 0x193C
|
||||
UserClip::Op user_clip_op; ///< 0x1940
|
||||
@@ -3482,7 +3482,7 @@ ASSERT_REG_POSITION(gl_cull_test_enabled, 0x1918);
|
||||
ASSERT_REG_POSITION(gl_front_face, 0x191C);
|
||||
ASSERT_REG_POSITION(gl_cull_face, 0x1920);
|
||||
ASSERT_REG_POSITION(viewport_pixel_center, 0x1924);
|
||||
ASSERT_REG_POSITION(viewport_scale_offset_enbled, 0x192C);
|
||||
ASSERT_REG_POSITION(viewport_scale_offset_enabled, 0x192C);
|
||||
ASSERT_REG_POSITION(viewport_clip_control, 0x193C);
|
||||
ASSERT_REG_POSITION(user_clip_op, 0x1940);
|
||||
ASSERT_REG_POSITION(render_enable_override, 0x1944);
|
||||
|
||||
@@ -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,
|
||||
|
||||
@@ -503,6 +503,17 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
float_image_scaling_mask, down_factor, 0.0f);
|
||||
}
|
||||
}
|
||||
if (info.uses_render_area) {
|
||||
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);
|
||||
} else {
|
||||
glProgramUniform4f(source_programs[stage].handle, 1, render_area_width,
|
||||
render_area_height, 0.0f, 0.0f);
|
||||
}
|
||||
}
|
||||
}};
|
||||
if constexpr (Spec::enabled_stages[0]) {
|
||||
prepare_stage(0);
|
||||
|
||||
@@ -618,6 +618,16 @@ void RasterizerOpenGL::SyncViewport() {
|
||||
}
|
||||
flags[Dirty::Viewport0 + index] = false;
|
||||
|
||||
if (!regs.viewport_scale_offset_enabled) {
|
||||
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;
|
||||
}
|
||||
|
||||
const auto& src = regs.viewport_transform[index];
|
||||
GLfloat x = conv(src.translate_x - src.scale_x);
|
||||
GLfloat y = conv(src.translate_y - src.scale_y);
|
||||
|
||||
@@ -49,7 +49,7 @@ using VideoCommon::LoadPipelines;
|
||||
using VideoCommon::SerializePipeline;
|
||||
using Context = ShaderContext::Context;
|
||||
|
||||
constexpr u32 CACHE_VERSION = 6;
|
||||
constexpr u32 CACHE_VERSION = 7;
|
||||
|
||||
template <typename Container>
|
||||
auto MakeSpan(Container& container) {
|
||||
@@ -76,7 +76,7 @@ Shader::RuntimeInfo MakeRuntimeInfo(const GraphicsPipelineKey& key,
|
||||
}
|
||||
break;
|
||||
case Shader::Stage::TessellationEval:
|
||||
// invert the face
|
||||
// Flip the face, as opengl's drawing is also flipped
|
||||
info.tess_clockwise = key.tessellation_clockwise == 0;
|
||||
info.tess_primitive = [&key] {
|
||||
switch (key.tessellation_primitive) {
|
||||
@@ -219,6 +219,7 @@ ShaderCache::ShaderCache(RasterizerOpenGL& rasterizer_, Core::Frontend::EmuWindo
|
||||
.support_float16 = false,
|
||||
.support_int64 = device.HasShaderInt64(),
|
||||
.needs_demote_reorder = device.IsAmd(),
|
||||
.support_snorm_render_buffer = false,
|
||||
} {
|
||||
if (use_asynchronous_shaders) {
|
||||
workers = CreateWorkers();
|
||||
|
||||
@@ -70,8 +70,8 @@ void SetupDirtyViewports(Tables& tables) {
|
||||
FillBlock(tables[1], OFF(viewport_transform), NUM(viewport_transform), Viewports);
|
||||
FillBlock(tables[1], OFF(viewports), NUM(viewports), Viewports);
|
||||
|
||||
tables[0][OFF(viewport_scale_offset_enbled)] = ViewportTransform;
|
||||
tables[1][OFF(viewport_scale_offset_enbled)] = Viewports;
|
||||
tables[0][OFF(viewport_scale_offset_enabled)] = ViewportTransform;
|
||||
tables[1][OFF(viewport_scale_offset_enabled)] = Viewports;
|
||||
}
|
||||
|
||||
void SetupDirtyScissors(Tables& tables) {
|
||||
|
||||
@@ -68,13 +68,15 @@ public:
|
||||
}
|
||||
|
||||
vk::PipelineLayout CreatePipelineLayout(VkDescriptorSetLayout descriptor_set_layout) const {
|
||||
using Shader::Backend::SPIRV::RenderAreaLayout;
|
||||
using Shader::Backend::SPIRV::RescalingLayout;
|
||||
const u32 size_offset = is_compute ? sizeof(RescalingLayout::down_factor) : 0u;
|
||||
const VkPushConstantRange range{
|
||||
.stageFlags = static_cast<VkShaderStageFlags>(
|
||||
is_compute ? VK_SHADER_STAGE_COMPUTE_BIT : VK_SHADER_STAGE_ALL_GRAPHICS),
|
||||
.offset = 0,
|
||||
.size = static_cast<u32>(sizeof(RescalingLayout)) - size_offset,
|
||||
.size = static_cast<u32>(sizeof(RescalingLayout)) - size_offset +
|
||||
static_cast<u32>(sizeof(RenderAreaLayout)),
|
||||
};
|
||||
return device->GetLogical().CreatePipelineLayout({
|
||||
.sType = VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO,
|
||||
@@ -167,6 +169,12 @@ private:
|
||||
u32 image_bit{1u};
|
||||
};
|
||||
|
||||
class RenderAreaPushConstant {
|
||||
public:
|
||||
bool uses_render_area{};
|
||||
std::array<f32, 4> words{};
|
||||
};
|
||||
|
||||
inline void PushImageDescriptors(TextureCache& texture_cache,
|
||||
UpdateDescriptorQueue& update_descriptor_queue,
|
||||
const Shader::Info& info, RescalingPushConstant& rescaling,
|
||||
|
||||
@@ -31,6 +31,7 @@ namespace {
|
||||
using boost::container::small_vector;
|
||||
using boost::container::static_vector;
|
||||
using Shader::ImageBufferDescriptor;
|
||||
using Shader::Backend::SPIRV::RENDERAREA_LAYOUT_OFFSET;
|
||||
using Shader::Backend::SPIRV::RESCALING_LAYOUT_DOWN_FACTOR_OFFSET;
|
||||
using Shader::Backend::SPIRV::RESCALING_LAYOUT_WORDS_OFFSET;
|
||||
using Tegra::Texture::TexturePair;
|
||||
@@ -433,12 +434,19 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
update_descriptor_queue.Acquire();
|
||||
|
||||
RescalingPushConstant rescaling;
|
||||
RenderAreaPushConstant render_area;
|
||||
const VkSampler* samplers_it{samplers.data()};
|
||||
const VideoCommon::ImageViewInOut* views_it{views.data()};
|
||||
const auto prepare_stage{[&](size_t stage) LAMBDA_FORCEINLINE {
|
||||
buffer_cache.BindHostStageBuffers(stage);
|
||||
PushImageDescriptors(texture_cache, update_descriptor_queue, stage_infos[stage], rescaling,
|
||||
samplers_it, views_it);
|
||||
const auto& info{stage_infos[0]};
|
||||
if (info.uses_render_area) {
|
||||
render_area.uses_render_area = true;
|
||||
render_area.words = {static_cast<float>(regs.surface_clip.width),
|
||||
static_cast<float>(regs.surface_clip.height)};
|
||||
}
|
||||
}};
|
||||
if constexpr (Spec::enabled_stages[0]) {
|
||||
prepare_stage(0);
|
||||
@@ -455,10 +463,11 @@ void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
if constexpr (Spec::enabled_stages[4]) {
|
||||
prepare_stage(4);
|
||||
}
|
||||
ConfigureDraw(rescaling);
|
||||
ConfigureDraw(rescaling, render_area);
|
||||
}
|
||||
|
||||
void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling) {
|
||||
void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling,
|
||||
const RenderAreaPushConstant& render_area) {
|
||||
texture_cache.UpdateRenderTargets(false);
|
||||
scheduler.RequestRenderpass(texture_cache.GetFramebuffer());
|
||||
|
||||
@@ -474,7 +483,9 @@ void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling) {
|
||||
const bool bind_pipeline{scheduler.UpdateGraphicsPipeline(this)};
|
||||
const void* const descriptor_data{update_descriptor_queue.UpdateData()};
|
||||
scheduler.Record([this, descriptor_data, bind_pipeline, rescaling_data = rescaling.Data(),
|
||||
is_rescaling, update_rescaling](vk::CommandBuffer cmdbuf) {
|
||||
is_rescaling, update_rescaling,
|
||||
uses_render_area = render_area.uses_render_area,
|
||||
render_area_data = render_area.words](vk::CommandBuffer cmdbuf) {
|
||||
if (bind_pipeline) {
|
||||
cmdbuf.BindPipeline(VK_PIPELINE_BIND_POINT_GRAPHICS, *pipeline);
|
||||
}
|
||||
@@ -488,6 +499,11 @@ void GraphicsPipeline::ConfigureDraw(const RescalingPushConstant& rescaling) {
|
||||
RESCALING_LAYOUT_DOWN_FACTOR_OFFSET, sizeof(scale_down_factor),
|
||||
&scale_down_factor);
|
||||
}
|
||||
if (uses_render_area) {
|
||||
cmdbuf.PushConstants(*pipeline_layout, VK_SHADER_STAGE_ALL_GRAPHICS,
|
||||
RENDERAREA_LAYOUT_OFFSET, sizeof(render_area_data),
|
||||
&render_area_data);
|
||||
}
|
||||
if (!descriptor_set_layout) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -62,6 +62,7 @@ class Device;
|
||||
class PipelineStatistics;
|
||||
class RenderPassCache;
|
||||
class RescalingPushConstant;
|
||||
class RenderAreaPushConstant;
|
||||
class Scheduler;
|
||||
class UpdateDescriptorQueue;
|
||||
|
||||
@@ -119,7 +120,8 @@ private:
|
||||
template <typename Spec>
|
||||
void ConfigureImpl(bool is_indexed);
|
||||
|
||||
void ConfigureDraw(const RescalingPushConstant& rescaling);
|
||||
void ConfigureDraw(const RescalingPushConstant& rescaling,
|
||||
const RenderAreaPushConstant& render_are);
|
||||
|
||||
void MakePipeline(VkRenderPass render_pass);
|
||||
|
||||
|
||||
@@ -53,7 +53,7 @@ using VideoCommon::FileEnvironment;
|
||||
using VideoCommon::GenericEnvironment;
|
||||
using VideoCommon::GraphicsEnvironment;
|
||||
|
||||
constexpr u32 CACHE_VERSION = 6;
|
||||
constexpr u32 CACHE_VERSION = 7;
|
||||
|
||||
template <typename Container>
|
||||
auto MakeSpan(Container& container) {
|
||||
@@ -326,6 +326,7 @@ PipelineCache::PipelineCache(RasterizerVulkan& rasterizer_, const Device& device
|
||||
.support_int64 = device.IsShaderInt64Supported(),
|
||||
.needs_demote_reorder = driver_id == VK_DRIVER_ID_AMD_PROPRIETARY_KHR ||
|
||||
driver_id == VK_DRIVER_ID_AMD_OPEN_SOURCE_KHR,
|
||||
.support_snorm_render_buffer = true,
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -683,6 +683,22 @@ void RasterizerVulkan::UpdateViewportsState(Tegra::Engines::Maxwell3D::Regs& reg
|
||||
if (!state_tracker.TouchViewports()) {
|
||||
return;
|
||||
}
|
||||
if (!regs.viewport_scale_offset_enabled) {
|
||||
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,
|
||||
.width = width != 0.0f ? width : 1.0f,
|
||||
.height = height != 0.0f ? height : 1.0f,
|
||||
.minDepth = 0.0f,
|
||||
.maxDepth = 1.0f,
|
||||
};
|
||||
scheduler.Record([viewport](vk::CommandBuffer cmdbuf) { cmdbuf.SetViewport(0, viewport); });
|
||||
return;
|
||||
}
|
||||
const bool is_rescaling{texture_cache.IsRescaling()};
|
||||
const float scale = is_rescaling ? Settings::values.resolution_info.up_factor : 1.0f;
|
||||
const std::array viewports{
|
||||
|
||||
@@ -51,7 +51,7 @@ Flags MakeInvalidationFlags() {
|
||||
void SetupDirtyViewports(Tables& tables) {
|
||||
FillBlock(tables[0], OFF(viewport_transform), NUM(viewport_transform), Viewports);
|
||||
FillBlock(tables[0], OFF(viewports), NUM(viewports), Viewports);
|
||||
tables[0][OFF(viewport_scale_offset_enbled)] = Viewports;
|
||||
tables[0][OFF(viewport_scale_offset_enabled)] = Viewports;
|
||||
tables[1][OFF(window_origin)] = Viewports;
|
||||
}
|
||||
|
||||
|
||||
@@ -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,22 +199,31 @@ 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))
|
||||
.write(reinterpret_cast<const char*>(&start_address), sizeof(start_address))
|
||||
.write(reinterpret_cast<const char*>(&cached_lowest), sizeof(cached_lowest))
|
||||
.write(reinterpret_cast<const char*>(&cached_highest), sizeof(cached_highest))
|
||||
.write(reinterpret_cast<const char*>(&viewport_transform_state),
|
||||
sizeof(viewport_transform_state))
|
||||
.write(reinterpret_cast<const char*>(&stage), sizeof(stage))
|
||||
.write(reinterpret_cast<const char*>(code.data()), code_size);
|
||||
for (const auto& [key, type] : texture_types) {
|
||||
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));
|
||||
@@ -237,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_,
|
||||
@@ -305,8 +333,27 @@ 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_scale_offset_enabled;
|
||||
return viewport_transform_state;
|
||||
}
|
||||
|
||||
ComputeEnvironment::ComputeEnvironment(Tegra::Engines::KeplerCompute& kepler_compute_,
|
||||
@@ -337,21 +384,41 @@ 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() {
|
||||
return viewport_transform_state;
|
||||
}
|
||||
|
||||
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))
|
||||
.read(reinterpret_cast<char*>(&start_address), sizeof(start_address))
|
||||
.read(reinterpret_cast<char*>(&read_lowest), sizeof(read_lowest))
|
||||
.read(reinterpret_cast<char*>(&read_highest), sizeof(read_highest))
|
||||
.read(reinterpret_cast<char*>(&viewport_transform_state), sizeof(viewport_transform_state))
|
||||
.read(reinterpret_cast<char*>(&stage), sizeof(stage));
|
||||
code = std::make_unique<u64[]>(Common::DivCeil(code_size, sizeof(u64)));
|
||||
file.read(reinterpret_cast<char*>(code.get()), code_size);
|
||||
@@ -362,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;
|
||||
@@ -409,6 +483,18 @@ 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;
|
||||
}
|
||||
|
||||
u32 FileEnvironment::LocalMemorySize() const {
|
||||
return local_memory_size;
|
||||
}
|
||||
|
||||
@@ -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{};
|
||||
@@ -85,6 +86,8 @@ protected:
|
||||
u32 cached_highest = 0;
|
||||
u32 initial_offset = 0;
|
||||
|
||||
u32 viewport_transform_state = 1;
|
||||
|
||||
bool has_unbound_instructions = false;
|
||||
};
|
||||
|
||||
@@ -102,6 +105,10 @@ public:
|
||||
|
||||
Shader::TextureType ReadTextureType(u32 handle) override;
|
||||
|
||||
Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
|
||||
|
||||
u32 ReadViewportTransformState() override;
|
||||
|
||||
private:
|
||||
Tegra::Engines::Maxwell3D* maxwell3d{};
|
||||
size_t stage_index{};
|
||||
@@ -120,6 +127,10 @@ public:
|
||||
|
||||
Shader::TextureType ReadTextureType(u32 handle) override;
|
||||
|
||||
Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
|
||||
|
||||
u32 ReadViewportTransformState() override;
|
||||
|
||||
private:
|
||||
Tegra::Engines::KeplerCompute* kepler_compute{};
|
||||
};
|
||||
@@ -143,6 +154,10 @@ public:
|
||||
|
||||
[[nodiscard]] Shader::TextureType ReadTextureType(u32 handle) override;
|
||||
|
||||
[[nodiscard]] Shader::TexturePixelFormat ReadTexturePixelFormat(u32 handle) override;
|
||||
|
||||
[[nodiscard]] u32 ReadViewportTransformState() override;
|
||||
|
||||
[[nodiscard]] u32 LocalMemorySize() const override;
|
||||
|
||||
[[nodiscard]] u32 SharedMemorySize() const override;
|
||||
@@ -156,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{};
|
||||
@@ -164,6 +180,7 @@ private:
|
||||
u32 read_lowest{};
|
||||
u32 read_highest{};
|
||||
u32 initial_offset{};
|
||||
u32 viewport_transform_state = 1;
|
||||
};
|
||||
|
||||
void SerializePipeline(std::span<const char> key, std::span<const GenericEnvironment* const> envs,
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user