Fix nvidia crash (API version). Fix linux builds

Properly set up vulkan API version when creating instance

Fix gcc error about passing function result by reference

Fix alot of warnings in VKGSRender project

More fixes for gcc

Fix texture create function
This commit is contained in:
kd-11 2016-03-07 17:55:02 +03:00
parent d58bd1c916
commit bd52bcf8d4
11 changed files with 40 additions and 44 deletions

View File

@ -340,7 +340,7 @@ std::vector<MipmapLevelInfo> upload_placed_texture(gsl::span<gsl::byte> mapped_b
/**
* Upload texture mipmaps where alignment and offset information is provided manually
*/
void upload_texture_mipmaps(gsl::span<gsl::byte> dst_buffer, const rsx::texture &texture, std::vector<std::pair<u32, u32>> alignment_offset_info)
void upload_texture_mipmaps(gsl::span<gsl::byte> dst_buffer, const rsx::texture &texture, std::vector<std::pair<u64, u32>> alignment_offset_info)
{
u16 w = texture.width(), h = texture.height();
u16 depth;

View File

@ -29,7 +29,7 @@ std::vector<MipmapLevelInfo> upload_placed_texture(gsl::span<gsl::byte> mapped_b
* alignment_offset info is an array of N mipmaps providing the offset into the data block and row-pitch alignment of each
* mipmap level individually.
*/
void upload_texture_mipmaps(gsl::span<gsl::byte> dst_buffer, const rsx::texture &texture, std::vector<std::pair<u32, u32>> alignment_offset_info);
void upload_texture_mipmaps(gsl::span<gsl::byte> dst_buffer, const rsx::texture &texture, std::vector<std::pair<u64, u32>> alignment_offset_info);
/**
* Get number of bytes occupied by texture in RSX mem

View File

@ -290,7 +290,7 @@ void VKFragmentProgram::Compile()
VkDevice dev = (VkDevice)*vk::get_current_renderer();
vkCreateShaderModule(dev, &fs_info, nullptr, &handle);
id = (u32)(handle);
id = (u32)((u64)handle);
}
void VKFragmentProgram::Delete()

View File

@ -47,7 +47,7 @@ public:
ParamArray parr;
VkShaderModule handle = nullptr;
int id;
u32 id;
std::string shader;
std::vector<size_t> FragmentConstantOffsetCache;

View File

@ -412,7 +412,7 @@ void VKGSRender::end()
}
}
auto &upload_info = upload_vertex_data();
auto upload_info = upload_vertex_data();
m_program->set_primitive_topology(std::get<0>(upload_info));
m_program->use(m_command_buffer, m_render_pass, 0);
@ -435,9 +435,6 @@ void VKGSRender::end()
end_command_buffer_recording();
execute_command_buffer(false);
//Finish()
vkDeviceWaitIdle((*m_device));
rsx::thread::end();
}
@ -519,7 +516,7 @@ void VKGSRender::clear_surface(u32 mask)
init_buffers();
float depth_clear = 1.f;
u32 stencil_clear = 0.f;
u32 stencil_clear = 0;
VkClearValue depth_stencil_clear_values, color_clear_values;
VkImageSubresourceRange depth_range = vk::default_image_subresource_range();
@ -874,7 +871,6 @@ void VKGSRender::prepare_rtts()
(*m_device), &m_command_buffer);
//Bind created rtts as current fbo...
VkImageView attachments[5];
std::vector<u8> draw_buffers = vk::get_draw_buffers(rsx::to_surface_target(rsx::method_registers[NV4097_SET_SURFACE_COLOR_TARGET]));
m_framebuffer.destroy();
@ -904,7 +900,7 @@ void VKGSRender::prepare_rtts()
init_render_pass(vk::get_compatible_surface_format(m_surface.color_format),
vk::get_compatible_depth_surface_format(m_surface.depth_format),
draw_buffers.size(),
(u8)draw_buffers.size(),
draw_buffers.data());
}

View File

@ -99,7 +99,7 @@ namespace vk
uint32_t get_queue_count()
{
if (queue_props.size())
return queue_props.size();
return (u32)queue_props.size();
uint32_t count = 0;
vkGetPhysicalDeviceQueueFamilyProperties(dev, &count, nullptr);
@ -239,13 +239,13 @@ namespace vk
{
VkDeviceMemory vram = nullptr;
vk::render_device *owner = nullptr;
u32 vram_block_sz = 0;
u64 vram_block_sz = 0;
public:
memory_block() {}
~memory_block() {}
void allocate_from_pool(vk::render_device &device, u32 block_sz, u32 typeBits)
void allocate_from_pool(vk::render_device &device, u64 block_sz, u32 typeBits)
{
if (vram)
destroy();
@ -322,9 +322,9 @@ namespace vk
texture() {}
~texture() {}
void create(vk::render_device &device, VkFormat format, VkImageType image_type, VkImageViewType view_type, VkImageCreateFlags image_flags, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle);
void create(vk::render_device &device, VkFormat format, VkImageType image_type, VkImageViewType view_type, VkImageCreateFlags image_flags, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only);
void create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height);
void destroy();
@ -360,7 +360,7 @@ namespace vk
vk::render_device *owner;
vk::memory_block vram;
u32 m_size = 0;
u64 m_size = 0;
bool viewable = false;
@ -368,7 +368,7 @@ namespace vk
buffer() {}
~buffer() {}
void create(vk::render_device &dev, u32 size, VkFormat format, VkBufferUsageFlagBits usage, VkBufferCreateFlags flags)
void create(vk::render_device &dev, u64 size, VkFormat format, VkBufferUsageFlagBits usage, VkBufferCreateFlags flags)
{
if (m_buffer) throw EXCEPTION("Buffer create called on an existing buffer!");
@ -504,7 +504,7 @@ namespace vk
m_internal_format = format;
}
u32 size()
u64 size()
{
return m_size;
}
@ -784,7 +784,7 @@ namespace vk
u32 get_swap_image_count()
{
return m_swap_images.size();
return (u32)m_swap_images.size();
}
vk::swap_chain_image& get_swap_chain_image(const int index)
@ -959,7 +959,7 @@ namespace vk
app.applicationVersion = 0;
app.pEngineName = app_name;
app.engineVersion = 0;
app.apiVersion = (1, 0, 0);
app.apiVersion = VK_MAKE_VERSION(1, 0, 0);
//Set up instance information
const char *requested_extensions[] =
@ -993,7 +993,7 @@ namespace vk
if (error != VK_SUCCESS) throw EXCEPTION("Undefined trap");
m_vk_instances.push_back(instance);
return m_vk_instances.size();
return (u32)m_vk_instances.size();
}
void makeCurrentInstance(uint32_t instance_id)
@ -1037,7 +1037,7 @@ namespace vk
CHECK_RESULT(vkEnumeratePhysicalDevices(m_instance, &num_gpus, pdevs.data()));
for (int i = 0; i < num_gpus; ++i)
for (u32 i = 0; i < num_gpus; ++i)
gpus[i].set_device(pdevs[i]);
}
@ -1060,7 +1060,7 @@ namespace vk
uint32_t device_queues = dev.get_queue_count();
std::vector<VkBool32> supportsPresent(device_queues);
for (int index = 0; index < device_queues; index++)
for (u32 index = 0; index < device_queues; index++)
{
vkGetPhysicalDeviceSurfaceSupportKHR(dev, index, surface, &supportsPresent[index]);
}
@ -1070,7 +1070,7 @@ namespace vk
uint32_t graphicsQueueNodeIndex = UINT32_MAX;
uint32_t presentQueueNodeIndex = UINT32_MAX;
for (int i = 0; i < device_queues; i++)
for (u32 i = 0; i < device_queues; i++)
{
if ((dev.get_queue_properties(i).queueFlags & VK_QUEUE_GRAPHICS_BIT) != 0)
{
@ -1206,8 +1206,8 @@ namespace vk
{
VkBufferView buffer_view = nullptr;
VkBuffer buffer = nullptr;
u32 offset = 0;
u32 size = 0;
u64 offset = 0;
u64 size = 0;
};
struct program_input

View File

@ -725,7 +725,7 @@ namespace vk
uniform.domain == domain)
{
VkBuffer buf = _buffer;
u32 size = _buffer.size();
u64 size = _buffer.size();
if (uniform.as_buffer.buffer != buf ||
uniform.as_buffer.size != size)
@ -760,7 +760,7 @@ namespace vk
{
VkBuffer buf = _buffer;
VkBufferView view = _buffer;
u32 size = _buffer.size();
u64 size = _buffer.size();
if (uniform.as_buffer.buffer != buf ||
uniform.as_buffer.buffer_view != view ||

View File

@ -66,7 +66,7 @@ namespace vk
if (dstLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
change_image_layout(cmd, dst, dstLayout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, aspect);
for (int mip_level = 0; mip_level < mipmaps; ++mip_level)
for (u32 mip_level = 0; mip_level < mipmaps; ++mip_level)
{
vkCmdCopyImage(cmd, src, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &rgn);
@ -105,7 +105,7 @@ namespace vk
if (dstLayout != VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL)
change_image_layout(cmd, dst, dstLayout, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, aspect);
for (int mip_level = 0; mip_level < mipmaps; ++mip_level)
for (u32 mip_level = 0; mip_level < mipmaps; ++mip_level)
{
vkCmdBlitImage(cmd, src, VK_IMAGE_LAYOUT_TRANSFER_SRC_OPTIMAL, dst, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, 1, &rgn, VK_FILTER_LINEAR);
@ -138,7 +138,7 @@ namespace vk
owner = nullptr;
}
void texture::create(vk::render_device &device, VkFormat format, VkImageType image_type, VkImageViewType view_type, VkImageCreateFlags image_flags, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle)
void texture::create(vk::render_device &device, VkFormat format, VkImageType image_type, VkImageViewType view_type, VkImageCreateFlags image_flags, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle)
{
owner = &device;
@ -224,12 +224,12 @@ namespace vk
ready = true;
}
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle)
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, VkImageTiling tiling, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle)
{
create(device, format, VK_IMAGE_TYPE_2D, VK_IMAGE_VIEW_TYPE_2D, 0, usage, tiling, width, height, mipmaps, gpu_only, swizzle);
}
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping& swizzle)
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only, VkComponentMapping swizzle)
{
VkImageTiling tiling = VK_IMAGE_TILING_OPTIMAL;
@ -250,7 +250,7 @@ namespace vk
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height, u32 mipmaps, bool gpu_only)
{
create(device, format, usage, width, height, mipmaps, gpu_only, vk::default_component_map());
create(device, format, usage, width, height, mipmaps, gpu_only, default_component_map());
}
void texture::create(vk::render_device &device, VkFormat format, VkImageUsageFlags usage, u32 width, u32 height)
@ -390,7 +390,7 @@ namespace vk
if (tex.mipmap() == 1)
{
u32 buffer_size = get_placed_texture_storage_size(tex, layout_alignment[0].first, layout_alignment[0].first);
u64 buffer_size = get_placed_texture_storage_size(tex, layout_alignment[0].first, layout_alignment[0].first);
if (buffer_size != layout_alignment[0].second.size)
{
if (buffer_size > layout_alignment[0].second.size)
@ -421,7 +421,7 @@ namespace vk
else
{
auto &layer_props = layout_alignment[layout_alignment.size() - 1].second;
u32 max_size = layer_props.offset + layer_props.size;
u64 max_size = layer_props.offset + layer_props.size;
if (m_memory_layout.size < max_size)
{
@ -429,14 +429,14 @@ namespace vk
}
int index= 0;
std::vector<std::pair<u32, u32>> layout_offset_info(tex.mipmap());
std::vector<std::pair<u64, u32>> layout_offset_info(tex.mipmap());
for (auto &mip_info : layout_offset_info)
{
auto &alignment = layout_alignment[index].first;
auto &layout = layout_alignment[index++].second;
mip_info = std::make_pair(layout.offset, layout.rowPitch);
mip_info = std::make_pair(layout.offset, (u32)layout.rowPitch);
}
CHECK_RESULT(vkMapMemory((*owner), vram_allocation, 0, m_memory_layout.size, 0, (void**)&data));

View File

@ -92,7 +92,7 @@ namespace vk
*/
u32 expand_line_loop_array_to_strip(u32 vertex_draw_count, std::vector<u16>& indices)
{
int i = 0;
u32 i = 0;
indices.resize(vertex_draw_count + 1);
for (; i < vertex_draw_count; ++i)
@ -107,7 +107,7 @@ namespace vk
{
indices.resize(original_count + 1);
int i = 0;
u32 i = 0;
for (; i < original_count; ++i)
indices[i] = original_indices[i];

View File

@ -269,7 +269,7 @@ void VKVertexProgram::Compile()
VkDevice dev = (VkDevice)*vk::get_current_renderer();
vkCreateShaderModule(dev, &vs_info, nullptr, &handle);
id = (u32)(handle);
id = (u32)((u64)handle);
}
void VKVertexProgram::Delete()

View File

@ -45,7 +45,7 @@ public:
ParamArray parr;
VkShaderModule handle = nullptr;
int id;
u32 id;
std::string shader;
std::vector<vk::glsl::program_input> uniforms;