mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2024-12-28 02:26:07 +00:00
video_core: renderer_vulkan: added color mask support
This commit is contained in:
parent
767e13cccb
commit
8e6d492524
|
@ -113,6 +113,11 @@ GraphicsPipeline::GraphicsPipeline(const Instance& instance_, Scheduler& schedul
|
|||
vk::DynamicState::eBlendConstants,
|
||||
};
|
||||
|
||||
if (instance.IsColorWriteEnableSupported()) {
|
||||
dynamic_states.push_back(vk::DynamicState::eColorWriteEnableEXT);
|
||||
dynamic_states.push_back(vk::DynamicState::eColorWriteMaskEXT);
|
||||
}
|
||||
|
||||
const vk::PipelineDynamicStateCreateInfo dynamic_info = {
|
||||
.dynamicStateCount = static_cast<u32>(dynamic_states.size()),
|
||||
.pDynamicStates = dynamic_states.data(),
|
||||
|
|
|
@ -115,6 +115,7 @@ bool Instance::CreateDevice() {
|
|||
vk::PhysicalDeviceCustomBorderColorFeaturesEXT, vk::PhysicalDeviceIndexTypeUint8FeaturesEXT,
|
||||
vk::PhysicalDeviceFragmentShaderInterlockFeaturesEXT,
|
||||
vk::PhysicalDevicePipelineCreationCacheControlFeaturesEXT,
|
||||
vk::PhysicalDeviceColorWriteEnableFeaturesEXT,
|
||||
vk::PhysicalDeviceFragmentShaderBarycentricFeaturesKHR>();
|
||||
const vk::StructureChain properties_chain =
|
||||
physical_device.getProperties2<vk::PhysicalDeviceProperties2,
|
||||
|
@ -150,6 +151,8 @@ bool Instance::CreateDevice() {
|
|||
tooling_info = add_extension(VK_EXT_TOOLING_INFO_EXTENSION_NAME);
|
||||
custom_border_color = add_extension(VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
|
||||
index_type_uint8 = add_extension(VK_KHR_INDEX_TYPE_UINT8_EXTENSION_NAME);
|
||||
color_write_en = add_extension(VK_EXT_COLOR_WRITE_ENABLE_EXTENSION_NAME);
|
||||
add_extension(VK_EXT_EXTENDED_DYNAMIC_STATE_3_EXTENSION_NAME);
|
||||
add_extension(VK_KHR_PUSH_DESCRIPTOR_EXTENSION_NAME);
|
||||
add_extension(VK_KHR_MAINTENANCE_4_EXTENSION_NAME);
|
||||
|
||||
|
@ -216,12 +219,22 @@ bool Instance::CreateDevice() {
|
|||
vk::PhysicalDeviceIndexTypeUint8FeaturesEXT{
|
||||
.indexTypeUint8 = true,
|
||||
},
|
||||
vk::PhysicalDeviceColorWriteEnableFeaturesEXT{
|
||||
.colorWriteEnable = true,
|
||||
},
|
||||
vk::PhysicalDeviceExtendedDynamicState3FeaturesEXT{
|
||||
.extendedDynamicState3ColorWriteMask = true,
|
||||
},
|
||||
};
|
||||
|
||||
if (!index_type_uint8) {
|
||||
device_chain.unlink<vk::PhysicalDeviceIndexTypeUint8FeaturesEXT>();
|
||||
}
|
||||
|
||||
if (!color_write_en) {
|
||||
device_chain.unlink<vk::PhysicalDeviceColorWriteEnableFeaturesEXT>();
|
||||
}
|
||||
|
||||
try {
|
||||
device = physical_device.createDeviceUnique(device_chain.get());
|
||||
} catch (vk::ExtensionNotPresentError& err) {
|
||||
|
|
|
@ -111,6 +111,11 @@ public:
|
|||
return external_memory_host;
|
||||
}
|
||||
|
||||
/// Returns true when VK_EXT_color_write_enable is supported
|
||||
bool IsColorWriteEnableSupported() const {
|
||||
return color_write_en;
|
||||
}
|
||||
|
||||
/// Returns the vendor ID of the physical device
|
||||
u32 GetVendorID() const {
|
||||
return properties.vendorID;
|
||||
|
@ -218,6 +223,7 @@ private:
|
|||
bool fragment_shader_barycentric{};
|
||||
bool shader_stencil_export{};
|
||||
bool external_memory_host{};
|
||||
bool color_write_en{};
|
||||
u64 min_imported_host_pointer_alignment{};
|
||||
bool tooling_info{};
|
||||
bool debug_utils_supported{};
|
||||
|
|
|
@ -138,6 +138,19 @@ void Rasterizer::UpdateDynamicState() {
|
|||
auto& regs = liverpool->regs;
|
||||
const auto cmdbuf = scheduler.CommandBuffer();
|
||||
cmdbuf.setBlendConstants(®s.blend_constants.red);
|
||||
|
||||
if (instance.IsColorWriteEnableSupported()) {
|
||||
std::array<VkBool32, Liverpool::NumColorBuffers> write_en{};
|
||||
std::array<vk::ColorComponentFlags, Liverpool::NumColorBuffers> write_mask{};
|
||||
for (int col_buf_idx = 0; col_buf_idx < Liverpool::NumColorBuffers; ++col_buf_idx) {
|
||||
const auto mask = regs.color_target_mask.raw >> (col_buf_idx * 4);
|
||||
write_en[col_buf_idx] = mask ? vk::True : vk::False;
|
||||
write_mask[col_buf_idx] = vk::ColorComponentFlags{mask};
|
||||
}
|
||||
|
||||
cmdbuf.setColorWriteEnableEXT(write_en);
|
||||
cmdbuf.setColorWriteMaskEXT(0, write_mask);
|
||||
}
|
||||
}
|
||||
|
||||
void Rasterizer::UpdateViewportScissorState() {
|
||||
|
|
Loading…
Reference in a new issue