mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-07-27 04:25:12 +00:00
shader_recompiler: Make most features optional
This commit is contained in:
parent
f619049bc3
commit
a36407bc5e
@ -174,14 +174,18 @@ Id DefineMain(EmitContext& ctx, IR::Program& program) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) {
|
void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) {
|
||||||
|
const auto& info = program.info;
|
||||||
const std::span interfaces(ctx.interfaces.data(), ctx.interfaces.size());
|
const std::span interfaces(ctx.interfaces.data(), ctx.interfaces.size());
|
||||||
spv::ExecutionModel execution_model{};
|
spv::ExecutionModel execution_model{};
|
||||||
ctx.AddCapability(spv::Capability::Image1D);
|
ctx.AddCapability(spv::Capability::Image1D);
|
||||||
ctx.AddCapability(spv::Capability::Sampled1D);
|
ctx.AddCapability(spv::Capability::Sampled1D);
|
||||||
|
if (info.uses_fp16) {
|
||||||
ctx.AddCapability(spv::Capability::Float16);
|
ctx.AddCapability(spv::Capability::Float16);
|
||||||
ctx.AddCapability(spv::Capability::Int16);
|
ctx.AddCapability(spv::Capability::Int16);
|
||||||
ctx.AddCapability(spv::Capability::StorageImageWriteWithoutFormat);
|
}
|
||||||
|
if (info.has_storage_images) {
|
||||||
ctx.AddCapability(spv::Capability::StorageImageExtendedFormats);
|
ctx.AddCapability(spv::Capability::StorageImageExtendedFormats);
|
||||||
|
}
|
||||||
switch (program.info.stage) {
|
switch (program.info.stage) {
|
||||||
case Stage::Compute: {
|
case Stage::Compute: {
|
||||||
const std::array<u32, 3> workgroup_size{program.info.workgroup_size};
|
const std::array<u32, 3> workgroup_size{program.info.workgroup_size};
|
||||||
@ -200,13 +204,19 @@ void DefineEntryPoint(const IR::Program& program, EmitContext& ctx, Id main) {
|
|||||||
} else {
|
} else {
|
||||||
ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft);
|
ctx.AddExecutionMode(main, spv::ExecutionMode::OriginUpperLeft);
|
||||||
}
|
}
|
||||||
if (program.info.uses_group_quad) {
|
if (info.uses_group_quad) {
|
||||||
ctx.AddCapability(spv::Capability::GroupNonUniform);
|
ctx.AddCapability(spv::Capability::GroupNonUniform);
|
||||||
ctx.AddCapability(spv::Capability::GroupNonUniformQuad);
|
ctx.AddCapability(spv::Capability::GroupNonUniformQuad);
|
||||||
}
|
}
|
||||||
|
if (info.has_discard) {
|
||||||
ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT);
|
ctx.AddCapability(spv::Capability::DemoteToHelperInvocationEXT);
|
||||||
|
}
|
||||||
|
if (info.has_image_gather) {
|
||||||
ctx.AddCapability(spv::Capability::ImageGatherExtended);
|
ctx.AddCapability(spv::Capability::ImageGatherExtended);
|
||||||
|
}
|
||||||
|
if (info.has_image_query) {
|
||||||
ctx.AddCapability(spv::Capability::ImageQuery);
|
ctx.AddCapability(spv::Capability::ImageQuery);
|
||||||
|
}
|
||||||
// if (program.info.stores_frag_depth) {
|
// if (program.info.stores_frag_depth) {
|
||||||
// ctx.AddExecutionMode(main, spv::ExecutionMode::DepthReplacing);
|
// ctx.AddExecutionMode(main, spv::ExecutionMode::DepthReplacing);
|
||||||
// }
|
// }
|
||||||
|
@ -74,21 +74,19 @@ Id EmitContext::Def(const IR::Value& value) {
|
|||||||
void EmitContext::DefineArithmeticTypes() {
|
void EmitContext::DefineArithmeticTypes() {
|
||||||
void_id = Name(TypeVoid(), "void_id");
|
void_id = Name(TypeVoid(), "void_id");
|
||||||
U1[1] = Name(TypeBool(), "bool_id");
|
U1[1] = Name(TypeBool(), "bool_id");
|
||||||
|
if (info.uses_fp16) {
|
||||||
F16[1] = Name(TypeFloat(16), "f16_id");
|
F16[1] = Name(TypeFloat(16), "f16_id");
|
||||||
|
U16 = Name(TypeUInt(16), "u16_id");
|
||||||
|
}
|
||||||
F32[1] = Name(TypeFloat(32), "f32_id");
|
F32[1] = Name(TypeFloat(32), "f32_id");
|
||||||
// F64[1] = Name(TypeFloat(64), "f64_id");
|
|
||||||
S32[1] = Name(TypeSInt(32), "i32_id");
|
S32[1] = Name(TypeSInt(32), "i32_id");
|
||||||
U32[1] = Name(TypeUInt(32), "u32_id");
|
U32[1] = Name(TypeUInt(32), "u32_id");
|
||||||
// U8 = Name(TypeSInt(8), "u8");
|
|
||||||
// S8 = Name(TypeUInt(8), "s8");
|
|
||||||
U16 = Name(TypeUInt(16), "u16_id");
|
|
||||||
// S16 = Name(TypeSInt(16), "s16_id");
|
|
||||||
// U64 = Name(TypeUInt(64), "u64_id");
|
|
||||||
|
|
||||||
for (u32 i = 2; i <= 4; i++) {
|
for (u32 i = 2; i <= 4; i++) {
|
||||||
|
if (info.uses_fp16) {
|
||||||
F16[i] = Name(TypeVector(F16[1], i), fmt::format("f16vec{}_id", i));
|
F16[i] = Name(TypeVector(F16[1], i), fmt::format("f16vec{}_id", i));
|
||||||
|
}
|
||||||
F32[i] = Name(TypeVector(F32[1], i), fmt::format("f32vec{}_id", i));
|
F32[i] = Name(TypeVector(F32[1], i), fmt::format("f32vec{}_id", i));
|
||||||
// F64[i] = Name(TypeVector(F64[1], i), fmt::format("f64vec{}_id", i));
|
|
||||||
S32[i] = Name(TypeVector(S32[1], i), fmt::format("i32vec{}_id", i));
|
S32[i] = Name(TypeVector(S32[1], i), fmt::format("i32vec{}_id", i));
|
||||||
U32[i] = Name(TypeVector(U32[1], i), fmt::format("u32vec{}_id", i));
|
U32[i] = Name(TypeVector(U32[1], i), fmt::format("u32vec{}_id", i));
|
||||||
U1[i] = Name(TypeVector(U1[1], i), fmt::format("bvec{}_id", i));
|
U1[i] = Name(TypeVector(U1[1], i), fmt::format("bvec{}_id", i));
|
||||||
|
@ -26,9 +26,27 @@ void Visit(Info& info, IR::Inst& inst) {
|
|||||||
case IR::Opcode::WriteSharedU16:
|
case IR::Opcode::WriteSharedU16:
|
||||||
info.uses_shared_u16 = true;
|
info.uses_shared_u16 = true;
|
||||||
break;
|
break;
|
||||||
|
case IR::Opcode::ConvertF32F16:
|
||||||
|
case IR::Opcode::BitCastF16U16:
|
||||||
|
info.uses_fp16 = true;
|
||||||
|
break;
|
||||||
|
case IR::Opcode::ImageWrite:
|
||||||
|
info.has_storage_images = true;
|
||||||
|
break;
|
||||||
case IR::Opcode::QuadShuffle:
|
case IR::Opcode::QuadShuffle:
|
||||||
info.uses_group_quad = true;
|
info.uses_group_quad = true;
|
||||||
break;
|
break;
|
||||||
|
case IR::Opcode::Discard:
|
||||||
|
info.has_discard = true;
|
||||||
|
break;
|
||||||
|
case IR::Opcode::ImageGather:
|
||||||
|
case IR::Opcode::ImageGatherDref:
|
||||||
|
info.has_image_gather = true;
|
||||||
|
break;
|
||||||
|
case IR::Opcode::ImageQueryDimensions:
|
||||||
|
case IR::Opcode::ImageQueryLod:
|
||||||
|
info.has_image_query = true;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -169,9 +169,14 @@ struct Info {
|
|||||||
uintptr_t pgm_base{};
|
uintptr_t pgm_base{};
|
||||||
u64 pgm_hash{};
|
u64 pgm_hash{};
|
||||||
u32 shared_memory_size{};
|
u32 shared_memory_size{};
|
||||||
|
bool has_storage_images{};
|
||||||
|
bool has_discard{};
|
||||||
|
bool has_image_gather{};
|
||||||
|
bool has_image_query{};
|
||||||
bool uses_group_quad{};
|
bool uses_group_quad{};
|
||||||
bool uses_shared_u8{};
|
bool uses_shared_u8{};
|
||||||
bool uses_shared_u16{};
|
bool uses_shared_u16{};
|
||||||
|
bool uses_fp16{};
|
||||||
bool translation_failed{}; // indicates that shader has unsupported instructions
|
bool translation_failed{}; // indicates that shader has unsupported instructions
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
|
@ -3,12 +3,6 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "common/assert.h"
|
|
||||||
#include "common/bit_field.h"
|
|
||||||
#include "common/types.h"
|
|
||||||
#include "resource.h"
|
|
||||||
#include "video_core/amdgpu/pixel_format.h"
|
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <condition_variable>
|
#include <condition_variable>
|
||||||
#include <coroutine>
|
#include <coroutine>
|
||||||
@ -16,6 +10,11 @@
|
|||||||
#include <span>
|
#include <span>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
#include <queue>
|
#include <queue>
|
||||||
|
#include "common/assert.h"
|
||||||
|
#include "common/bit_field.h"
|
||||||
|
#include "common/types.h"
|
||||||
|
#include "video_core/amdgpu/pixel_format.h"
|
||||||
|
#include "video_core/amdgpu/resource.h"
|
||||||
|
|
||||||
namespace Vulkan {
|
namespace Vulkan {
|
||||||
class Rasterizer;
|
class Rasterizer;
|
||||||
|
@ -114,6 +114,7 @@ bool Instance::CreateDevice() {
|
|||||||
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT,
|
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT,
|
||||||
vk::PhysicalDeviceCustomBorderColorFeaturesEXT,
|
vk::PhysicalDeviceCustomBorderColorFeaturesEXT,
|
||||||
vk::PhysicalDeviceColorWriteEnableFeaturesEXT, vk::PhysicalDeviceVulkan12Features,
|
vk::PhysicalDeviceColorWriteEnableFeaturesEXT, vk::PhysicalDeviceVulkan12Features,
|
||||||
|
vk::PhysicalDeviceVulkan13Features,
|
||||||
vk::PhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR,
|
vk::PhysicalDeviceWorkgroupMemoryExplicitLayoutFeaturesKHR,
|
||||||
vk::PhysicalDeviceDepthClipControlFeaturesEXT>();
|
vk::PhysicalDeviceDepthClipControlFeaturesEXT>();
|
||||||
const vk::StructureChain properties_chain =
|
const vk::StructureChain properties_chain =
|
||||||
@ -189,6 +190,7 @@ bool Instance::CreateDevice() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const auto vk12_features = feature_chain.get<vk::PhysicalDeviceVulkan12Features>();
|
const auto vk12_features = feature_chain.get<vk::PhysicalDeviceVulkan12Features>();
|
||||||
|
const auto vk13_features = feature_chain.get<vk::PhysicalDeviceVulkan13Features>();
|
||||||
vk::StructureChain device_chain = {
|
vk::StructureChain device_chain = {
|
||||||
vk::DeviceCreateInfo{
|
vk::DeviceCreateInfo{
|
||||||
.queueCreateInfoCount = 1u,
|
.queueCreateInfoCount = 1u,
|
||||||
@ -223,9 +225,9 @@ bool Instance::CreateDevice() {
|
|||||||
.timelineSemaphore = vk12_features.timelineSemaphore,
|
.timelineSemaphore = vk12_features.timelineSemaphore,
|
||||||
},
|
},
|
||||||
vk::PhysicalDeviceVulkan13Features{
|
vk::PhysicalDeviceVulkan13Features{
|
||||||
.shaderDemoteToHelperInvocation = true,
|
.shaderDemoteToHelperInvocation = vk13_features.shaderDemoteToHelperInvocation,
|
||||||
.dynamicRendering = true,
|
.dynamicRendering = vk13_features.dynamicRendering,
|
||||||
.maintenance4 = true,
|
.maintenance4 = vk13_features.maintenance4,
|
||||||
},
|
},
|
||||||
vk::PhysicalDeviceCustomBorderColorFeaturesEXT{
|
vk::PhysicalDeviceCustomBorderColorFeaturesEXT{
|
||||||
.customBorderColors = true,
|
.customBorderColors = true,
|
||||||
|
Loading…
Reference in New Issue
Block a user