[shader_recompiler/Maxwell] ISBERD add size reads
Some checks failed
eden-license / license-header (pull_request) Failing after 26s
Some checks failed
eden-license / license-header (pull_request) Failing after 26s
This commit is contained in:
parent
51b170b470
commit
92c6e92558
6 changed files with 492 additions and 436 deletions
|
@ -240,6 +240,7 @@ add_library(shader_recompiler STATIC
|
|||
runtime_info.h
|
||||
shader_info.h
|
||||
varying_state.h
|
||||
frontend/maxwell/translate/impl/internal_stage_buffer_entry_read.h
|
||||
)
|
||||
|
||||
if (YUZU_USE_EXTERNAL_VULKAN_SPIRV_TOOLS)
|
||||
|
|
|
@ -268,4 +268,40 @@ void TranslatorVisitor::ResetOFlag() {
|
|||
SetOFlag(ir.Imm1(false));
|
||||
}
|
||||
|
||||
IR::U32 TranslatorVisitor::apply_ISBERD_shift(IR::U32 result, isberd::Shift shift_value) {
|
||||
if (shift_value != isberd::Shift::Default) {
|
||||
return ir.ShiftLeftLogical(result, ir.Imm32(1));
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
IR::U32 TranslatorVisitor::apply_ISBERD_size_read(IR::U32 address, isberd::SZ sz) {
|
||||
switch (sz) {
|
||||
case isberd::SZ::U8:
|
||||
return ir.LoadGlobalU8(ir.UConvert(64, address));
|
||||
case isberd::SZ::U16:
|
||||
return ir.LoadGlobalU16(ir.UConvert(64, address));
|
||||
case isberd::SZ::U32:
|
||||
case isberd::SZ::F32:
|
||||
return ir.LoadGlobal32(ir.UConvert(64, address));
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
IR::U32 TranslatorVisitor::compute_ISBERD_address(IR::Reg src_reg, u32 src_reg_num, u32 imm, u64 skew_value) {
|
||||
IR::U32 address{};
|
||||
if (src_reg_num == 0xFF) {
|
||||
address = ir.Imm32(imm);
|
||||
} else {
|
||||
auto offset = ir.Imm32(imm);
|
||||
address = ir.IAdd(X(src_reg), offset);
|
||||
if (skew_value != 0) {
|
||||
address = ir.IAdd(address, ir.LaneId());
|
||||
}
|
||||
}
|
||||
|
||||
return address;
|
||||
};
|
||||
|
||||
} // namespace Shader::Maxwell
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
#include "shader_recompiler/frontend/maxwell/instruction.h"
|
||||
#include "shader_recompiler/frontend/maxwell/translate/impl/internal_stage_buffer_entry_read.h"
|
||||
|
||||
namespace Shader::Maxwell {
|
||||
|
||||
|
@ -381,6 +382,11 @@ public:
|
|||
void ResetSFlag();
|
||||
void ResetCFlag();
|
||||
void ResetOFlag();
|
||||
|
||||
// Helper functions for various translator visitors
|
||||
IR::U32 apply_ISBERD_shift(IR::U32 result, isberd::Shift shift_value);
|
||||
IR::U32 apply_ISBERD_size_read(IR::U32 address, isberd::SZ sz_value);
|
||||
IR::U32 compute_ISBERD_address(IR::Reg src_reg, u32 src_reg_num, u32 imm, u64 skew_value);
|
||||
};
|
||||
|
||||
} // namespace Shader::Maxwell
|
||||
|
|
|
@ -7,23 +7,9 @@
|
|||
#include "common/bit_field.h"
|
||||
#include "common/common_types.h"
|
||||
#include "shader_recompiler/frontend/maxwell/translate/impl/impl.h"
|
||||
#include "shader_recompiler/frontend/maxwell/translate/impl/internal_stage_buffer_entry_read.h"
|
||||
|
||||
namespace Shader::Maxwell {
|
||||
namespace {
|
||||
enum class Mode : u64 {
|
||||
Default,
|
||||
Patch,
|
||||
Prim,
|
||||
Attr,
|
||||
};
|
||||
|
||||
enum class Shift : u64 {
|
||||
Default,
|
||||
U16,
|
||||
B32,
|
||||
};
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
// Valid only for GS, TI, VS and trap
|
||||
void TranslatorVisitor::ISBERD(u64 insn) {
|
||||
|
@ -35,70 +21,49 @@ void TranslatorVisitor::ISBERD(u64 insn) {
|
|||
BitField<24, 8, u32> imm;
|
||||
BitField<31, 1, u64> skew;
|
||||
BitField<32, 1, u64> o;
|
||||
BitField<33, 2, Mode> mode;
|
||||
BitField<47, 2, Shift> shift;
|
||||
BitField<33, 2, isberd::Mode> mode;
|
||||
BitField<36, 4, isberd::SZ> sz;
|
||||
BitField<47, 2, isberd::Shift> shift;
|
||||
} const isberd{insn};
|
||||
|
||||
if (isberd.skew != 0) {
|
||||
IR::U32 current_lane_id{ir.LaneId()};
|
||||
IR::U32 result{ir.IAdd(X(isberd.src_reg), current_lane_id)};
|
||||
X(isberd.dest_reg, result);
|
||||
}
|
||||
auto address = compute_ISBERD_address(isberd.src_reg, isberd.src_reg_num, isberd.imm, isberd.skew);
|
||||
if (isberd.o != 0) {
|
||||
IR::U32 address{};
|
||||
IR::F32 result{};
|
||||
if (isberd.src_reg_num == 0xFF) {
|
||||
address = ir.Imm32(isberd.imm);
|
||||
result = ir.GetAttributeIndexed(address);
|
||||
} else {
|
||||
IR::U32 offset = ir.Imm32(isberd.imm);
|
||||
address = ir.IAdd(X(isberd.src_reg), offset);
|
||||
result = ir.GetAttributeIndexed(address);
|
||||
}
|
||||
X(isberd.dest_reg, ir.BitCast<IR::U32>(result));
|
||||
}
|
||||
if (isberd.mode != Mode::Default) {
|
||||
IR::F32 result{};
|
||||
IR::U32 index{};
|
||||
if (isberd.src_reg_num == 0xFF) {
|
||||
index = ir.Imm32(isberd.imm);
|
||||
} else {
|
||||
index = ir.IAdd(X(isberd.src_reg), ir.Imm32(isberd.imm));
|
||||
auto result = apply_ISBERD_size_read(address, isberd.sz.Value());
|
||||
X(isberd.dest_reg, apply_ISBERD_shift(result, isberd.shift.Value()));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
switch (static_cast<u64>(isberd.mode.Value())) {
|
||||
case static_cast<u64>(Mode::Patch):
|
||||
result = ir.GetPatch(index.Patch());
|
||||
if (isberd.mode != isberd::Mode::Default) {
|
||||
IR::F32 result_f32{};
|
||||
switch (isberd.mode.Value()) {
|
||||
case isberd::Mode::Patch:
|
||||
result_f32 = ir.GetPatch(address.Patch());
|
||||
break;
|
||||
case static_cast<u64>(Mode::Prim):
|
||||
result = ir.GetAttribute(index.Attribute());
|
||||
case isberd::Mode::Prim:
|
||||
result_f32 = ir.GetAttribute(address.Attribute());
|
||||
break;
|
||||
case static_cast<u64>(Mode::Attr):
|
||||
result = ir.GetAttributeIndexed(index);
|
||||
case isberd::Mode::Attr:
|
||||
result_f32 = ir.GetAttributeIndexed(address);
|
||||
break;
|
||||
default:
|
||||
UNREACHABLE();
|
||||
}
|
||||
X(isberd.dest_reg, ir.BitCast<IR::U32>(result));
|
||||
}
|
||||
if (isberd.shift != Shift::Default) {
|
||||
IR::U32 result{};
|
||||
switch (static_cast<u64>(isberd.shift.Value())) {
|
||||
case static_cast<u64>(Shift::U16):
|
||||
result = ir.ShiftLeftLogical(result, static_cast<IR::U32>(ir.Imm16(1)));
|
||||
break;
|
||||
case static_cast<u64>(Shift::B32):
|
||||
result = ir.ShiftLeftLogical(result, ir.Imm32(1));
|
||||
break;
|
||||
|
||||
auto result_u32 = ir.BitCast<IR::U32>(result_f32);
|
||||
X(isberd.dest_reg, apply_ISBERD_shift(result_u32, isberd.shift.Value()));
|
||||
return;
|
||||
}
|
||||
|
||||
if (isberd.skew != 0) {
|
||||
auto result = ir.IAdd(X(isberd.src_reg), ir.LaneId());
|
||||
X(isberd.dest_reg, result);
|
||||
|
||||
return;
|
||||
}
|
||||
//LOG_DEBUG(Shader, "(STUBBED) called {}", insn);
|
||||
if (isberd.src_reg_num == 0xFF) {
|
||||
IR::U32 src_imm{ir.Imm32(static_cast<u32>(isberd.imm))};
|
||||
IR::U32 result{ir.IAdd(X(isberd.src_reg), src_imm)};
|
||||
X(isberd.dest_reg, result);
|
||||
} else {
|
||||
|
||||
// Fallback if nothing else applies
|
||||
X(isberd.dest_reg, X(isberd.src_reg));
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Shader::Maxwell
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
// SPDX-FileCopyrightText: Copyright 2025 Eden Emulator Project
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
#pragma once
|
||||
#include "shader_recompiler/environment.h"
|
||||
#include "shader_recompiler/frontend/ir/basic_block.h"
|
||||
#include "shader_recompiler/frontend/ir/ir_emitter.h"
|
||||
#include "shader_recompiler/frontend/maxwell/instruction.h"
|
||||
|
||||
namespace Shader::Maxwell {
|
||||
namespace isberd {
|
||||
enum class Mode : u64 {
|
||||
Default,
|
||||
Patch,
|
||||
Prim,
|
||||
Attr,
|
||||
};
|
||||
|
||||
enum class Shift : u64 {
|
||||
Default,
|
||||
U16,
|
||||
B32,
|
||||
};
|
||||
|
||||
enum class SZ : u64 {
|
||||
U8,
|
||||
U16,
|
||||
U32,
|
||||
F32,
|
||||
};
|
||||
|
||||
} // Anonymous namespace
|
||||
|
||||
} // namespace Shader::Maxwell
|
|
@ -1,5 +1,5 @@
|
|||
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project
|
||||
# SPDX-License-Identifier: GPL-2.0-or-later
|
||||
# SPDX-FileCopyrightText: 2018 yuzu Emulator Project SPDX-License-Identifier:
|
||||
# GPL-2.0-or-later
|
||||
|
||||
add_subdirectory(host_shaders)
|
||||
|
||||
|
@ -9,7 +9,8 @@ if(LIBVA_FOUND)
|
|||
list(APPEND FFmpeg_LIBRARIES ${LIBVA_LIBRARIES})
|
||||
endif()
|
||||
|
||||
add_library(video_core STATIC
|
||||
add_library(
|
||||
video_core STATIC
|
||||
buffer_cache/buffer_base.h
|
||||
buffer_cache/buffer_cache_base.h
|
||||
buffer_cache/buffer_cache.cpp
|
||||
|
@ -312,13 +313,12 @@ add_library(video_core STATIC
|
|||
vulkan_common/nsight_aftermath_tracker.h
|
||||
vulkan_common/vma.cpp
|
||||
vulkan_common/vma.h
|
||||
vulkan_common/vulkan.h
|
||||
)
|
||||
vulkan_common/vulkan.h)
|
||||
|
||||
target_link_libraries(video_core PUBLIC common core)
|
||||
target_link_libraries(video_core PUBLIC glad shader_recompiler stb bc_decoder)
|
||||
|
||||
if (YUZU_USE_BUNDLED_FFMPEG AND NOT (WIN32 OR ANDROID))
|
||||
if(YUZU_USE_BUNDLED_FFMPEG AND NOT (WIN32 OR ANDROID))
|
||||
add_dependencies(video_core ffmpeg-build)
|
||||
endif()
|
||||
|
||||
|
@ -329,82 +329,96 @@ target_link_options(video_core PRIVATE ${FFmpeg_LDFLAGS})
|
|||
add_dependencies(video_core host_shaders)
|
||||
target_include_directories(video_core PRIVATE ${HOST_SHADERS_INCLUDE})
|
||||
|
||||
if (VulkanMemoryAllocator_ADDED)
|
||||
target_include_directories(video_core PUBLIC ${VulkanMemoryAllocator_SOURCE_DIR}/include)
|
||||
if(VulkanMemoryAllocator_ADDED)
|
||||
target_include_directories(video_core
|
||||
PUBLIC ${VulkanMemoryAllocator_SOURCE_DIR}/include)
|
||||
endif()
|
||||
|
||||
target_link_libraries(video_core PRIVATE sirit Vulkan::Headers VulkanUtilityHeaders)
|
||||
# target_link_libraries(video_core PRIVATE sirit Vulkan::Headers
|
||||
# VulkanUtilityHeaders)
|
||||
|
||||
if (ENABLE_NSIGHT_AFTERMATH)
|
||||
if (NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
|
||||
message(FATAL_ERROR "Environment variable NSIGHT_AFTERMATH_SDK has to be provided")
|
||||
if(ENABLE_NSIGHT_AFTERMATH)
|
||||
if(NOT DEFINED ENV{NSIGHT_AFTERMATH_SDK})
|
||||
message(
|
||||
FATAL_ERROR "Environment variable NSIGHT_AFTERMATH_SDK has to be provided"
|
||||
)
|
||||
endif()
|
||||
if (NOT WIN32)
|
||||
message(FATAL_ERROR "Nsight Aftermath doesn't support non-Windows platforms")
|
||||
if(NOT WIN32)
|
||||
message(
|
||||
FATAL_ERROR "Nsight Aftermath doesn't support non-Windows platforms")
|
||||
endif()
|
||||
target_compile_definitions(video_core PRIVATE HAS_NSIGHT_AFTERMATH)
|
||||
target_include_directories(video_core PRIVATE "$ENV{NSIGHT_AFTERMATH_SDK}/include")
|
||||
target_include_directories(video_core
|
||||
PRIVATE "$ENV{NSIGHT_AFTERMATH_SDK}/include")
|
||||
endif()
|
||||
|
||||
if (MSVC)
|
||||
target_compile_options(video_core PRIVATE
|
||||
/we4242 # 'identifier': conversion from 'type1' to 'type2', possible loss of data
|
||||
/we4244 # 'conversion': conversion from 'type1' to 'type2', possible loss of data
|
||||
if(MSVC)
|
||||
target_compile_options(
|
||||
video_core
|
||||
PRIVATE /we4242 # 'identifier': conversion from 'type1' to 'type2', possible
|
||||
# loss of data
|
||||
/we4244 # 'conversion': conversion from 'type1' to 'type2', possible
|
||||
# loss of data
|
||||
)
|
||||
else()
|
||||
if (APPLE)
|
||||
# error: declaration shadows a typedef in 'interval_base_set<SubType, DomainT, Compare, Interval, Alloc>'
|
||||
# error: implicit conversion loses integer precision: 'int' to 'boost::icl::bound_type' (aka 'unsigned char')
|
||||
target_compile_options(video_core PRIVATE -Wno-shadow -Wno-unused-local-typedef)
|
||||
if(APPLE)
|
||||
# error: declaration shadows a typedef in 'interval_base_set<SubType,
|
||||
# DomainT, Compare, Interval, Alloc>' error: implicit conversion loses
|
||||
# integer precision: 'int' to 'boost::icl::bound_type' (aka 'unsigned char')
|
||||
target_compile_options(video_core PRIVATE -Wno-shadow
|
||||
-Wno-unused-local-typedef)
|
||||
else()
|
||||
target_compile_options(video_core PRIVATE -Werror=conversion)
|
||||
endif()
|
||||
|
||||
target_compile_options(video_core PRIVATE
|
||||
-Wno-sign-conversion
|
||||
)
|
||||
target_compile_options(video_core PRIVATE -Wno-sign-conversion)
|
||||
|
||||
# xbyak
|
||||
set_source_files_properties(macro/macro_jit_x64.cpp PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-shadow")
|
||||
set_source_files_properties(
|
||||
macro/macro_jit_x64.cpp PROPERTIES COMPILE_OPTIONS
|
||||
"-Wno-conversion;-Wno-shadow")
|
||||
|
||||
# VMA
|
||||
set_source_files_properties(vulkan_common/vma.cpp PROPERTIES COMPILE_OPTIONS "-Wno-conversion;-Wno-unused-variable;-Wno-unused-parameter;-Wno-missing-field-initializers")
|
||||
set_source_files_properties(
|
||||
vulkan_common/vma.cpp
|
||||
PROPERTIES
|
||||
COMPILE_OPTIONS
|
||||
"-Wno-conversion;-Wno-unused-variable;-Wno-unused-parameter;-Wno-missing-field-initializers"
|
||||
)
|
||||
|
||||
# Get around GCC failing with intrinsics in Debug
|
||||
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_BUILD_TYPE MATCHES "Debug")
|
||||
set_source_files_properties(host1x/vic.cpp PROPERTIES COMPILE_OPTIONS "-O2")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_x86_64)
|
||||
target_sources(video_core PRIVATE
|
||||
macro/macro_jit_x64.cpp
|
||||
macro/macro_jit_x64.h
|
||||
)
|
||||
if(ARCHITECTURE_x86_64)
|
||||
target_sources(video_core PRIVATE macro/macro_jit_x64.cpp
|
||||
macro/macro_jit_x64.h)
|
||||
target_link_libraries(video_core PUBLIC xbyak::xbyak)
|
||||
|
||||
if (NOT MSVC)
|
||||
if(NOT MSVC)
|
||||
target_compile_options(video_core PRIVATE -msse4.1)
|
||||
endif()
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
|
||||
if(ARCHITECTURE_x86_64 OR ARCHITECTURE_arm64)
|
||||
target_link_libraries(video_core PRIVATE dynarmic::dynarmic)
|
||||
endif()
|
||||
|
||||
if (YUZU_USE_PRECOMPILED_HEADERS)
|
||||
if(YUZU_USE_PRECOMPILED_HEADERS)
|
||||
target_precompile_headers(video_core PRIVATE precompiled_headers.h)
|
||||
endif()
|
||||
|
||||
if (YUZU_ENABLE_LTO)
|
||||
if(YUZU_ENABLE_LTO)
|
||||
set_property(TARGET video_core PROPERTY INTERPROCEDURAL_OPTIMIZATION TRUE)
|
||||
endif()
|
||||
|
||||
if (ANDROID AND ARCHITECTURE_arm64)
|
||||
if(ANDROID AND ARCHITECTURE_arm64)
|
||||
target_link_libraries(video_core PRIVATE adrenotools)
|
||||
endif()
|
||||
|
||||
if (ARCHITECTURE_arm64)
|
||||
if(ARCHITECTURE_arm64)
|
||||
target_link_libraries(video_core PRIVATE sse2neon)
|
||||
endif()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue