mirror of
https://github.com/RPCS3/rpcs3.git
synced 2025-07-12 09:48:37 +12:00
commit
0c231e6578
9 changed files with 53 additions and 50 deletions
|
@ -37,6 +37,8 @@ namespace vk
|
||||||
{
|
{
|
||||||
switch (gl_name)
|
switch (gl_name)
|
||||||
{
|
{
|
||||||
|
case CELL_GCM_NEVER:
|
||||||
|
return VK_COMPARE_OP_NEVER;
|
||||||
case CELL_GCM_GREATER:
|
case CELL_GCM_GREATER:
|
||||||
return VK_COMPARE_OP_GREATER;
|
return VK_COMPARE_OP_GREATER;
|
||||||
case CELL_GCM_LESS:
|
case CELL_GCM_LESS:
|
||||||
|
@ -257,7 +259,7 @@ namespace
|
||||||
|
|
||||||
VkRenderPassCreateInfo rp_info = {};
|
VkRenderPassCreateInfo rp_info = {};
|
||||||
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
rp_info.sType = VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO;
|
||||||
rp_info.attachmentCount = attachments.size();
|
rp_info.attachmentCount = static_cast<uint32_t>(attachments.size());
|
||||||
rp_info.pAttachments = attachments.data();
|
rp_info.pAttachments = attachments.data();
|
||||||
rp_info.subpassCount = 1;
|
rp_info.subpassCount = 1;
|
||||||
rp_info.pSubpasses = &subpass;
|
rp_info.pSubpasses = &subpass;
|
||||||
|
@ -335,7 +337,7 @@ namespace
|
||||||
VkDescriptorSetLayoutCreateInfo infos = {};
|
VkDescriptorSetLayoutCreateInfo infos = {};
|
||||||
infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
infos.sType = VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO;
|
||||||
infos.pBindings = bindings.data();
|
infos.pBindings = bindings.data();
|
||||||
infos.bindingCount = bindings.size();
|
infos.bindingCount = static_cast<uint32_t>(bindings.size());
|
||||||
|
|
||||||
VkDescriptorSetLayout set_layout;
|
VkDescriptorSetLayout set_layout;
|
||||||
CHECK_RESULT(vkCreateDescriptorSetLayout(dev, &infos, nullptr, &set_layout));
|
CHECK_RESULT(vkCreateDescriptorSetLayout(dev, &infos, nullptr, &set_layout));
|
||||||
|
@ -417,7 +419,7 @@ VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
|
||||||
|
|
||||||
std::vector<VkDescriptorPoolSize> sizes{ uniform_buffer_pool, uniform_texel_pool, texture_pool };
|
std::vector<VkDescriptorPoolSize> sizes{ uniform_buffer_pool, uniform_texel_pool, texture_pool };
|
||||||
|
|
||||||
descriptor_pool.create(*m_device, sizes.data(), sizes.size());
|
descriptor_pool.create(*m_device, sizes.data(), static_cast<uint32_t>(sizes.size()));
|
||||||
|
|
||||||
|
|
||||||
null_buffer = std::make_unique<vk::buffer>(*m_device, 32, m_memory_type_mapping.host_visible_coherent, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0);
|
null_buffer = std::make_unique<vk::buffer>(*m_device, 32, m_memory_type_mapping.host_visible_coherent, VK_BUFFER_USAGE_UNIFORM_TEXEL_BUFFER_BIT, 0);
|
||||||
|
@ -436,7 +438,7 @@ VKGSRender::VKGSRender() : GSRender(frame_type::Vulkan)
|
||||||
|
|
||||||
VKGSRender::~VKGSRender()
|
VKGSRender::~VKGSRender()
|
||||||
{
|
{
|
||||||
CHECK_RESULT(vkQueueWaitIdle(m_swap_chain->get_present_queue()));
|
vkQueueWaitIdle(m_swap_chain->get_present_queue());
|
||||||
|
|
||||||
if (m_present_semaphore)
|
if (m_present_semaphore)
|
||||||
{
|
{
|
||||||
|
@ -677,9 +679,10 @@ void VKGSRender::clear_surface(u32 mask)
|
||||||
VkClearValue depth_stencil_clear_values, color_clear_values;
|
VkClearValue depth_stencil_clear_values, color_clear_values;
|
||||||
VkImageSubresourceRange depth_range = vk::get_image_subresource_range(0, 0, 1, 1, 0);
|
VkImageSubresourceRange depth_range = vk::get_image_subresource_range(0, 0, 1, 1, 0);
|
||||||
|
|
||||||
|
rsx::surface_depth_format surface_depth_format = rsx::to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7);
|
||||||
|
|
||||||
if (mask & 0x1)
|
if (mask & 0x1)
|
||||||
{
|
{
|
||||||
rsx::surface_depth_format surface_depth_format = rsx::to_surface_depth_format((rsx::method_registers[NV4097_SET_SURFACE_FORMAT] >> 5) & 0x7);
|
|
||||||
u32 max_depth_value = get_max_depth_value(surface_depth_format);
|
u32 max_depth_value = get_max_depth_value(surface_depth_format);
|
||||||
|
|
||||||
u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8;
|
u32 clear_depth = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] >> 8;
|
||||||
|
@ -690,7 +693,7 @@ void VKGSRender::clear_surface(u32 mask)
|
||||||
depth_stencil_clear_values.depthStencil.stencil = stencil_clear;
|
depth_stencil_clear_values.depthStencil.stencil = stencil_clear;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* if (mask & 0x2)
|
if (mask & 0x2)
|
||||||
{
|
{
|
||||||
u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff;
|
u8 clear_stencil = rsx::method_registers[NV4097_SET_ZSTENCIL_CLEAR_VALUE] & 0xff;
|
||||||
u32 stencil_mask = rsx::method_registers[NV4097_SET_STENCIL_MASK];
|
u32 stencil_mask = rsx::method_registers[NV4097_SET_STENCIL_MASK];
|
||||||
|
@ -698,7 +701,7 @@ void VKGSRender::clear_surface(u32 mask)
|
||||||
//TODO set stencil mask
|
//TODO set stencil mask
|
||||||
depth_range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
depth_range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
depth_stencil_clear_values.depthStencil.stencil = stencil_mask;
|
depth_stencil_clear_values.depthStencil.stencil = stencil_mask;
|
||||||
}*/
|
}
|
||||||
|
|
||||||
if (mask & 0xF0)
|
if (mask & 0xF0)
|
||||||
{
|
{
|
||||||
|
@ -733,11 +736,11 @@ void VKGSRender::clear_surface(u32 mask)
|
||||||
|
|
||||||
if (mask & 0x3)
|
if (mask & 0x3)
|
||||||
{
|
{
|
||||||
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT);
|
VkImageAspectFlags depth_stencil_aspect = (surface_depth_format == rsx::surface_depth_format::z24s8) ? (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT) : VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
VkImage depth_stencil_image = std::get<1>(m_rtts.m_bound_depth_stencil)->value;
|
VkImage depth_stencil_image = std::get<1>(m_rtts.m_bound_depth_stencil)->value;
|
||||||
change_image_layout(m_command_buffer, depth_stencil_image, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, range);
|
change_image_layout(m_command_buffer, depth_stencil_image, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, VK_IMAGE_LAYOUT_GENERAL, vk::get_image_subresource_range(0, 0, 1, 1, depth_stencil_aspect));
|
||||||
vkCmdClearDepthStencilImage(m_command_buffer, std::get<1>(m_rtts.m_bound_depth_stencil)->value, VK_IMAGE_LAYOUT_GENERAL, &depth_stencil_clear_values.depthStencil, 1, &depth_range);
|
vkCmdClearDepthStencilImage(m_command_buffer, std::get<1>(m_rtts.m_bound_depth_stencil)->value, VK_IMAGE_LAYOUT_GENERAL, &depth_stencil_clear_values.depthStencil, 1, &depth_range);
|
||||||
change_image_layout(m_command_buffer, depth_stencil_image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, range);
|
change_image_layout(m_command_buffer, depth_stencil_image, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, vk::get_image_subresource_range(0, 0, 1, 1, depth_stencil_aspect));
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -999,7 +1002,7 @@ void VKGSRender::close_and_submit_command_buffer(const std::vector<VkSemaphore>
|
||||||
infos.pCommandBuffers = &cmd;
|
infos.pCommandBuffers = &cmd;
|
||||||
infos.pWaitDstStageMask = &pipe_stage_flags;
|
infos.pWaitDstStageMask = &pipe_stage_flags;
|
||||||
infos.pWaitSemaphores = semaphores.data();
|
infos.pWaitSemaphores = semaphores.data();
|
||||||
infos.waitSemaphoreCount = semaphores.size();
|
infos.waitSemaphoreCount = static_cast<uint32_t>(semaphores.size());
|
||||||
infos.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
infos.sType = VK_STRUCTURE_TYPE_SUBMIT_INFO;
|
||||||
|
|
||||||
CHECK_RESULT(vkQueueSubmit(m_swap_chain->get_present_queue(), 1, &infos, fence));
|
CHECK_RESULT(vkQueueSubmit(m_swap_chain->get_present_queue(), 1, &infos, fence));
|
||||||
|
@ -1068,14 +1071,14 @@ void VKGSRender::prepare_rtts()
|
||||||
fbo_images.push_back(std::make_unique<vk::image_view>(*m_device, raw->value, VK_IMAGE_VIEW_TYPE_2D, raw->info.format, vk::default_component_map(), subres));
|
fbo_images.push_back(std::make_unique<vk::image_view>(*m_device, raw->value, VK_IMAGE_VIEW_TYPE_2D, raw->info.format, vk::default_component_map(), subres));
|
||||||
}
|
}
|
||||||
|
|
||||||
m_draw_buffers_count = fbo_images.size();
|
m_draw_buffers_count = static_cast<u32>(fbo_images.size());
|
||||||
|
|
||||||
if (std::get<1>(m_rtts.m_bound_depth_stencil) != nullptr)
|
if (std::get<1>(m_rtts.m_bound_depth_stencil) != nullptr)
|
||||||
{
|
{
|
||||||
vk::image *raw = (std::get<1>(m_rtts.m_bound_depth_stencil));
|
vk::image *raw = (std::get<1>(m_rtts.m_bound_depth_stencil));
|
||||||
|
|
||||||
VkImageSubresourceRange subres = {};
|
VkImageSubresourceRange subres = {};
|
||||||
subres.aspectMask = VK_IMAGE_ASPECT_DEPTH_BIT;
|
subres.aspectMask = (m_surface.depth_format == rsx::surface_depth_format::z24s8) ? (VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT) : VK_IMAGE_ASPECT_DEPTH_BIT;
|
||||||
subres.baseArrayLayer = 0;
|
subres.baseArrayLayer = 0;
|
||||||
subres.baseMipLevel = 0;
|
subres.baseMipLevel = 0;
|
||||||
subres.layerCount = 1;
|
subres.layerCount = 1;
|
||||||
|
@ -1131,7 +1134,6 @@ void VKGSRender::flip(int buffer)
|
||||||
}
|
}
|
||||||
|
|
||||||
VkSwapchainKHR swap_chain = (VkSwapchainKHR)(*m_swap_chain);
|
VkSwapchainKHR swap_chain = (VkSwapchainKHR)(*m_swap_chain);
|
||||||
uint32_t next_image_temp = 0;
|
|
||||||
|
|
||||||
//Prepare surface for new frame
|
//Prepare surface for new frame
|
||||||
CHECK_RESULT(vkAcquireNextImageKHR((*m_device), (*m_swap_chain), 0, m_present_semaphore, VK_NULL_HANDLE, &m_current_present_image));
|
CHECK_RESULT(vkAcquireNextImageKHR((*m_device), (*m_swap_chain), 0, m_present_semaphore, VK_NULL_HANDLE, &m_current_present_image));
|
||||||
|
@ -1154,12 +1156,11 @@ void VKGSRender::flip(int buffer)
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//No draw call was issued!
|
//No draw call was issued!
|
||||||
//TODO: Properly clear the background to rsx value
|
|
||||||
m_swap_chain->acquireNextImageKHR((*m_device), (*m_swap_chain), ~0ULL, VK_NULL_HANDLE, VK_NULL_HANDLE, &next_image_temp);
|
|
||||||
|
|
||||||
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT);
|
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_COLOR_BIT);
|
||||||
VkClearColorValue clear_black = { 0 };
|
VkClearColorValue clear_black = { 0 };
|
||||||
vkCmdClearColorImage(m_command_buffer, m_swap_chain->get_swap_chain_image(next_image_temp), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, &clear_black, 1, &range);
|
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, VK_IMAGE_LAYOUT_GENERAL, range);
|
||||||
|
vkCmdClearColorImage(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, &clear_black, 1, &range);
|
||||||
|
vk::change_image_layout(m_command_buffer, m_swap_chain->get_swap_chain_image(m_current_present_image), VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_PRESENT_SRC_KHR, range);
|
||||||
}
|
}
|
||||||
|
|
||||||
close_and_submit_command_buffer({ m_present_semaphore }, m_submit_fence);
|
close_and_submit_command_buffer({ m_present_semaphore }, m_submit_fence);
|
||||||
|
@ -1173,10 +1174,6 @@ void VKGSRender::flip(int buffer)
|
||||||
present.pImageIndices = &m_current_present_image;
|
present.pImageIndices = &m_current_present_image;
|
||||||
CHECK_RESULT(m_swap_chain->queuePresentKHR(m_swap_chain->get_present_queue(), &present));
|
CHECK_RESULT(m_swap_chain->queuePresentKHR(m_swap_chain->get_present_queue(), &present));
|
||||||
|
|
||||||
CHECK_RESULT(vkResetFences(*m_device, 1, &m_submit_fence));
|
|
||||||
CHECK_RESULT(vkResetCommandPool(*m_device, m_command_buffer_pool, 0));
|
|
||||||
open_command_buffer();
|
|
||||||
|
|
||||||
m_uniform_buffer_ring_info.m_get_pos = m_uniform_buffer_ring_info.get_current_put_pos_minus_one();
|
m_uniform_buffer_ring_info.m_get_pos = m_uniform_buffer_ring_info.get_current_put_pos_minus_one();
|
||||||
m_index_buffer_ring_info.m_get_pos = m_index_buffer_ring_info.get_current_put_pos_minus_one();
|
m_index_buffer_ring_info.m_get_pos = m_index_buffer_ring_info.get_current_put_pos_minus_one();
|
||||||
m_attrib_ring_info.m_get_pos = m_attrib_ring_info.get_current_put_pos_minus_one();
|
m_attrib_ring_info.m_get_pos = m_attrib_ring_info.get_current_put_pos_minus_one();
|
||||||
|
@ -1192,8 +1189,10 @@ void VKGSRender::flip(int buffer)
|
||||||
m_framebuffer_to_clean.clear();
|
m_framebuffer_to_clean.clear();
|
||||||
|
|
||||||
vkResetDescriptorPool(*m_device, descriptor_pool, 0);
|
vkResetDescriptorPool(*m_device, descriptor_pool, 0);
|
||||||
|
CHECK_RESULT(vkResetFences(*m_device, 1, &m_submit_fence));
|
||||||
|
CHECK_RESULT(vkResetCommandPool(*m_device, m_command_buffer_pool, 0));
|
||||||
|
open_command_buffer();
|
||||||
|
|
||||||
m_draw_calls = 0;
|
m_draw_calls = 0;
|
||||||
dirty_frame = true;
|
|
||||||
m_frame->flip(m_context);
|
m_frame->flip(m_context);
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,7 +61,6 @@ private:
|
||||||
|
|
||||||
vk::command_pool m_command_buffer_pool;
|
vk::command_pool m_command_buffer_pool;
|
||||||
vk::command_buffer m_command_buffer;
|
vk::command_buffer m_command_buffer;
|
||||||
bool dirty_frame = true;
|
|
||||||
|
|
||||||
|
|
||||||
std::array<VkRenderPass, 120> m_render_passes;
|
std::array<VkRenderPass, 120> m_render_passes;
|
||||||
|
@ -75,7 +74,6 @@ private:
|
||||||
std::vector<std::unique_ptr<vk::sampler> > m_sampler_to_clean;
|
std::vector<std::unique_ptr<vk::sampler> > m_sampler_to_clean;
|
||||||
|
|
||||||
u32 m_draw_calls = 0;
|
u32 m_draw_calls = 0;
|
||||||
|
|
||||||
u8 m_draw_buffers_count = 0;
|
u8 m_draw_buffers_count = 0;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -43,7 +43,7 @@ namespace vk
|
||||||
result.device_local = VK_MAX_MEMORY_TYPES;
|
result.device_local = VK_MAX_MEMORY_TYPES;
|
||||||
result.host_visible_coherent = VK_MAX_MEMORY_TYPES;
|
result.host_visible_coherent = VK_MAX_MEMORY_TYPES;
|
||||||
|
|
||||||
for (int i = 0; i < memory_properties.memoryTypeCount; i++)
|
for (u32 i = 0; i < memory_properties.memoryTypeCount; i++)
|
||||||
{
|
{
|
||||||
bool is_device_local = !!(memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
bool is_device_local = !!(memory_properties.memoryTypes[i].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
|
||||||
if (is_device_local)
|
if (is_device_local)
|
||||||
|
|
|
@ -181,7 +181,7 @@ namespace vk
|
||||||
device.pNext = NULL;
|
device.pNext = NULL;
|
||||||
device.queueCreateInfoCount = 1;
|
device.queueCreateInfoCount = 1;
|
||||||
device.pQueueCreateInfos = &queue;
|
device.pQueueCreateInfos = &queue;
|
||||||
device.enabledLayerCount = layers.size();
|
device.enabledLayerCount = static_cast<uint32_t>(layers.size());
|
||||||
device.ppEnabledLayerNames = layers.data();
|
device.ppEnabledLayerNames = layers.data();
|
||||||
device.enabledExtensionCount = 1;
|
device.enabledExtensionCount = 1;
|
||||||
device.ppEnabledExtensionNames = requested_extensions;
|
device.ppEnabledExtensionNames = requested_extensions;
|
||||||
|
@ -343,7 +343,7 @@ namespace vk
|
||||||
VkImageType image_type,
|
VkImageType image_type,
|
||||||
VkFormat format,
|
VkFormat format,
|
||||||
uint32_t width, uint32_t height, uint32_t depth,
|
uint32_t width, uint32_t height, uint32_t depth,
|
||||||
VkDeviceSize mipmaps, VkDeviceSize layers,
|
uint32_t mipmaps, uint32_t layers,
|
||||||
VkSampleCountFlagBits samples,
|
VkSampleCountFlagBits samples,
|
||||||
VkImageLayout initial_layout,
|
VkImageLayout initial_layout,
|
||||||
VkImageTiling tiling,
|
VkImageTiling tiling,
|
||||||
|
@ -496,7 +496,7 @@ namespace vk
|
||||||
vkDestroyBuffer(m_device, value, nullptr);
|
vkDestroyBuffer(m_device, value, nullptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void *map(u32 offset, u64 size)
|
void *map(u64 offset, u64 size)
|
||||||
{
|
{
|
||||||
void *data = nullptr;
|
void *data = nullptr;
|
||||||
CHECK_RESULT(vkMapMemory(m_device, memory->memory, offset, size, 0, &data));
|
CHECK_RESULT(vkMapMemory(m_device, memory->memory, offset, size, 0, &data));
|
||||||
|
@ -604,7 +604,7 @@ namespace vk
|
||||||
info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
info.sType = VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO;
|
||||||
info.width = width;
|
info.width = width;
|
||||||
info.height = height;
|
info.height = height;
|
||||||
info.attachmentCount = image_view_array.size();
|
info.attachmentCount = static_cast<uint32_t>(image_view_array.size());
|
||||||
info.pAttachments = image_view_array.data();
|
info.pAttachments = image_view_array.data();
|
||||||
info.renderPass = pass;
|
info.renderPass = pass;
|
||||||
info.layers = 1;
|
info.layers = 1;
|
||||||
|
@ -1044,7 +1044,7 @@ namespace vk
|
||||||
VkInstanceCreateInfo instance_info = {};
|
VkInstanceCreateInfo instance_info = {};
|
||||||
instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
instance_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO;
|
||||||
instance_info.pApplicationInfo = &app;
|
instance_info.pApplicationInfo = &app;
|
||||||
instance_info.enabledLayerCount = layers.size();
|
instance_info.enabledLayerCount = static_cast<uint32_t>(layers.size());
|
||||||
instance_info.ppEnabledLayerNames = layers.data();
|
instance_info.ppEnabledLayerNames = layers.data();
|
||||||
instance_info.enabledExtensionCount = 3;
|
instance_info.enabledExtensionCount = 3;
|
||||||
instance_info.ppEnabledExtensionNames = requested_extensions;
|
instance_info.ppEnabledExtensionNames = requested_extensions;
|
||||||
|
|
|
@ -23,7 +23,7 @@ namespace rsx
|
||||||
rtt.reset(new vk::image(device, mem_mapping.device_local,
|
rtt.reset(new vk::image(device, mem_mapping.device_local,
|
||||||
VK_IMAGE_TYPE_2D,
|
VK_IMAGE_TYPE_2D,
|
||||||
requested_format,
|
requested_format,
|
||||||
width, height, 1, 1, 1,
|
static_cast<uint32_t>(width), static_cast<uint32_t>(height), 1, 1, 1,
|
||||||
VK_SAMPLE_COUNT_1_BIT,
|
VK_SAMPLE_COUNT_1_BIT,
|
||||||
VK_IMAGE_LAYOUT_UNDEFINED,
|
VK_IMAGE_LAYOUT_UNDEFINED,
|
||||||
VK_IMAGE_TILING_OPTIMAL,
|
VK_IMAGE_TILING_OPTIMAL,
|
||||||
|
@ -48,24 +48,25 @@ namespace rsx
|
||||||
static std::unique_ptr<vk::image> create_new_surface(u32 address, surface_depth_format format, size_t width, size_t height, vk::render_device &device, vk::command_buffer *cmd, const vk::gpu_formats_support &support, const vk::memory_type_mapping &mem_mapping)
|
static std::unique_ptr<vk::image> create_new_surface(u32 address, surface_depth_format format, size_t width, size_t height, vk::render_device &device, vk::command_buffer *cmd, const vk::gpu_formats_support &support, const vk::memory_type_mapping &mem_mapping)
|
||||||
{
|
{
|
||||||
VkFormat requested_format = vk::get_compatible_depth_surface_format(support, format);
|
VkFormat requested_format = vk::get_compatible_depth_surface_format(support, format);
|
||||||
|
|
||||||
std::unique_ptr<vk::image> ds;
|
|
||||||
ds.reset(new vk::image(device, mem_mapping.device_local,
|
|
||||||
VK_IMAGE_TYPE_2D, requested_format, width, height, 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, 0));
|
|
||||||
change_image_layout(*cmd, ds->value, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
|
|
||||||
|
|
||||||
//Clear new surface..
|
|
||||||
VkClearDepthStencilValue clear_depth = {};
|
|
||||||
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT);
|
VkImageSubresourceRange range = vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT);
|
||||||
|
|
||||||
if (requested_format != VK_FORMAT_D16_UNORM)
|
if (requested_format != VK_FORMAT_D16_UNORM)
|
||||||
range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
range.aspectMask |= VK_IMAGE_ASPECT_STENCIL_BIT;
|
||||||
|
|
||||||
|
std::unique_ptr<vk::image> ds;
|
||||||
|
ds.reset(new vk::image(device, mem_mapping.device_local,
|
||||||
|
VK_IMAGE_TYPE_2D, requested_format, static_cast<uint32_t>(width), static_cast<uint32_t>(height), 1, 1, 1, VK_SAMPLE_COUNT_1_BIT, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT|VK_IMAGE_USAGE_SAMPLED_BIT, 0));
|
||||||
|
change_image_layout(*cmd, ds->value, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_GENERAL, range);
|
||||||
|
|
||||||
|
//Clear new surface..
|
||||||
|
VkClearDepthStencilValue clear_depth = {};
|
||||||
|
|
||||||
|
|
||||||
clear_depth.depth = 1.f;
|
clear_depth.depth = 1.f;
|
||||||
clear_depth.stencil = 0;
|
clear_depth.stencil = 0;
|
||||||
|
|
||||||
vkCmdClearDepthStencilImage(*cmd, ds->value, VK_IMAGE_LAYOUT_GENERAL, &clear_depth, 1, &range);
|
vkCmdClearDepthStencilImage(*cmd, ds->value, VK_IMAGE_LAYOUT_GENERAL, &clear_depth, 1, &range);
|
||||||
change_image_layout(*cmd, ds->value, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, vk::get_image_subresource_range(0, 0, 1, 1, VK_IMAGE_ASPECT_DEPTH_BIT | VK_IMAGE_ASPECT_STENCIL_BIT));
|
change_image_layout(*cmd, ds->value, VK_IMAGE_LAYOUT_GENERAL, VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL, range);
|
||||||
|
|
||||||
return ds;
|
return ds;
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,7 +138,7 @@ namespace vk
|
||||||
for (const rsx_subresource_layout &layout : subresource_layout)
|
for (const rsx_subresource_layout &layout : subresource_layout)
|
||||||
{
|
{
|
||||||
u32 row_pitch = align(layout.width_in_block * block_size_in_bytes, 256);
|
u32 row_pitch = align(layout.width_in_block * block_size_in_bytes, 256);
|
||||||
size_t image_linear_size = row_pitch * layout.height_in_block * layout.depth;
|
u32 image_linear_size = row_pitch * layout.height_in_block * layout.depth;
|
||||||
size_t offset_in_buffer = upload_heap.alloc<512>(image_linear_size);
|
size_t offset_in_buffer = upload_heap.alloc<512>(image_linear_size);
|
||||||
|
|
||||||
void *mapped_buffer = upload_buffer->map(offset_in_buffer, image_linear_size);
|
void *mapped_buffer = upload_buffer->map(offset_in_buffer, image_linear_size);
|
||||||
|
|
|
@ -119,12 +119,12 @@ namespace vk
|
||||||
obj.protected_rgn_end = (u32)align(obj.native_rsx_size, memory_page_size);
|
obj.protected_rgn_end = (u32)align(obj.native_rsx_size, memory_page_size);
|
||||||
obj.protected_rgn_end += obj.protected_rgn_start;
|
obj.protected_rgn_end += obj.protected_rgn_start;
|
||||||
|
|
||||||
lock_memory_region(obj.protected_rgn_start, obj.native_rsx_size);
|
lock_memory_region(static_cast<u32>(obj.protected_rgn_start), static_cast<u32>(obj.native_rsx_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void unlock_object(cached_texture_object &obj)
|
void unlock_object(cached_texture_object &obj)
|
||||||
{
|
{
|
||||||
unlock_memory_region(obj.protected_rgn_start, obj.native_rsx_size);
|
unlock_memory_region(static_cast<u32>(obj.protected_rgn_start), static_cast<u32>(obj.native_rsx_size));
|
||||||
}
|
}
|
||||||
|
|
||||||
void purge_dirty_textures()
|
void purge_dirty_textures()
|
||||||
|
|
|
@ -99,7 +99,7 @@ namespace vk
|
||||||
indices[i] = i;
|
indices[i] = i;
|
||||||
|
|
||||||
indices[i] = 0;
|
indices[i] = 0;
|
||||||
return indices.size();
|
return static_cast<u32>(indices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -112,7 +112,7 @@ namespace vk
|
||||||
indices[i] = original_indices[i];
|
indices[i] = original_indices[i];
|
||||||
|
|
||||||
indices[i] = original_indices[0];
|
indices[i] = original_indices[0];
|
||||||
return indices.size();
|
return static_cast<u32>(indices.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -454,7 +454,7 @@ VKGSRender::upload_vertex_data()
|
||||||
{
|
{
|
||||||
case rsx::vertex_base_type::f:
|
case rsx::vertex_base_type::f:
|
||||||
{
|
{
|
||||||
const u32 num_stored_verts = data_size / (sizeof(float) * vertex_info.size);
|
const u32 num_stored_verts = static_cast<u32>(data_size / (sizeof(float) * vertex_info.size));
|
||||||
vk::expand_array_components<float, 3, 4, 1>(reinterpret_cast<float*>(vertex_data.data()), converted_buffer, num_stored_verts);
|
vk::expand_array_components<float, 3, 4, 1>(reinterpret_cast<float*>(vertex_data.data()), converted_buffer, num_stored_verts);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -532,7 +532,7 @@ VKGSRender::upload_vertex_data()
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
index_count = get_index_count(draw_mode, vertex_draw_count);
|
index_count = static_cast<u32>(get_index_count(draw_mode, vertex_draw_count));
|
||||||
std::vector<u16> indices(index_count);
|
std::vector<u16> indices(index_count);
|
||||||
|
|
||||||
if (is_indexed_draw)
|
if (is_indexed_draw)
|
||||||
|
@ -568,7 +568,7 @@ VKGSRender::upload_vertex_data()
|
||||||
index_format = VK_INDEX_TYPE_UINT16;
|
index_format = VK_INDEX_TYPE_UINT16;
|
||||||
VkFormat fmt = VK_FORMAT_R16_UINT;
|
VkFormat fmt = VK_FORMAT_R16_UINT;
|
||||||
|
|
||||||
u32 elem_size = get_index_type_size(indexed_type);
|
u32 elem_size = static_cast<u32>(get_index_type_size(indexed_type));
|
||||||
|
|
||||||
if (indexed_type == rsx::index_array_type::u32)
|
if (indexed_type == rsx::index_array_type::u32)
|
||||||
{
|
{
|
||||||
|
@ -576,7 +576,7 @@ VKGSRender::upload_vertex_data()
|
||||||
fmt = VK_FORMAT_R32_UINT;
|
fmt = VK_FORMAT_R32_UINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
u32 index_sz = vertex_index_array.size() / elem_size;
|
u32 index_sz = static_cast<u32>(vertex_index_array.size()) / elem_size;
|
||||||
if (index_sz != vertex_draw_count)
|
if (index_sz != vertex_draw_count)
|
||||||
LOG_ERROR(RSX, "Vertex draw count mismatch!");
|
LOG_ERROR(RSX, "Vertex draw count mismatch!");
|
||||||
|
|
||||||
|
|
|
@ -100,6 +100,7 @@
|
||||||
<Optimization>Disabled</Optimization>
|
<Optimization>Disabled</Optimization>
|
||||||
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -115,6 +116,7 @@
|
||||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||||
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
<PreprocessorDefinitions>NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||||
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
<Link>
|
<Link>
|
||||||
<SubSystem>Windows</SubSystem>
|
<SubSystem>Windows</SubSystem>
|
||||||
|
@ -125,16 +127,19 @@
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release - LLVM|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - MemLeak|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
|
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug - LLVM|x64'">
|
||||||
<ClCompile>
|
<ClCompile>
|
||||||
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
<AdditionalIncludeDirectories>..\Vulkan\Vulkan-LoaderAndValidationLayers\include;..\Vulkan\glslang\glslang\Public;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||||
|
<TreatWarningAsError>true</TreatWarningAsError>
|
||||||
</ClCompile>
|
</ClCompile>
|
||||||
</ItemDefinitionGroup>
|
</ItemDefinitionGroup>
|
||||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue