Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Vulkan 断言条件修正 #438

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,7 @@ namespace Piccolo
RHIBuffer* vertex_buffers[] = {mesh->mesh_vertex_position_buffer};
RHIDeviceSize offsets[] = {0};
m_rhi->cmdBindVertexBuffersPFN(m_rhi->getCurrentCommandBuffer(), 0, 1, vertex_buffers, offsets);
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(), mesh->mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT16);
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(), mesh->mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT32);

uint32_t drawcall_max_instance_count =
(sizeof(MeshDirectionalLightShadowPerdrawcallStorageBufferObject::mesh_instances) /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2202,7 +2202,8 @@ namespace Piccolo
(sizeof(vertex_buffers) / sizeof(vertex_buffers[0])),
vertex_buffers,
offsets);
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT16);
m_rhi->cmdBindIndexBufferPFN(
m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT32);

uint32_t drawcall_max_instance_count =
(sizeof(MeshPerdrawcallStorageBufferObject::mesh_instances) /
Expand Down Expand Up @@ -2474,7 +2475,7 @@ namespace Piccolo
(sizeof(vertex_buffers) / sizeof(vertex_buffers[0])),
vertex_buffers,
offsets);
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT16);
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT32);

uint32_t drawcall_max_instance_count =
(sizeof(MeshPerdrawcallStorageBufferObject::mesh_instances) /
Expand Down Expand Up @@ -2697,7 +2698,7 @@ namespace Piccolo
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(),
m_visiable_nodes.p_axis_node->ref_mesh->mesh_index_buffer,
0,
RHI_INDEX_TYPE_UINT16);
RHI_INDEX_TYPE_UINT32);
(*reinterpret_cast<AxisStorageBufferObject*>(reinterpret_cast<uintptr_t>(
m_global_render_resource->_storage_buffer._axis_inefficient_storage_buffer_memory_pointer))) =
m_axis_storage_buffer_object;
Expand Down
2 changes: 1 addition & 1 deletion engine/source/runtime/function/render/passes/pick_pass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -577,7 +577,7 @@ namespace Piccolo
m_rhi->cmdBindIndexBufferPFN(m_rhi->getCurrentCommandBuffer(),
mesh.mesh_index_buffer,
0,
RHI_INDEX_TYPE_UINT16);
RHI_INDEX_TYPE_UINT32);

uint32_t drawcall_max_instance_count =
(sizeof(MeshInefficientPickPerdrawcallStorageBufferObject::model_matrices) /
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ namespace Piccolo
m_rhi->cmdBindVertexBuffersPFN(
m_rhi->getCurrentCommandBuffer(), 0, 1, vertex_buffers, offsets);
m_rhi->cmdBindIndexBufferPFN(
m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT16);
m_rhi->getCurrentCommandBuffer(), mesh.mesh_index_buffer, 0, RHI_INDEX_TYPE_UINT32);

uint32_t drawcall_max_instance_count =
(sizeof(MeshPointLightShadowPerdrawcallStorageBufferObject::mesh_instances) /
Expand Down
23 changes: 11 additions & 12 deletions engine/source/runtime/function/render/render_resource_base.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,11 +70,10 @@ namespace Piccolo
if (!texture->m_pixels)
return nullptr;

texture->m_width = iw;
texture->m_height = ih;
texture->m_format = (is_srgb) ? RHIFormat::RHI_FORMAT_R8G8B8A8_SRGB :
RHIFormat::RHI_FORMAT_R8G8B8A8_UNORM;
texture->m_depth = 1;
texture->m_width = iw;
texture->m_height = ih;
texture->m_format = (is_srgb) ? RHIFormat::RHI_FORMAT_R8G8B8A8_SRGB : RHIFormat::RHI_FORMAT_R8G8B8A8_UNORM;
texture->m_depth = 1;
texture->m_array_layers = 1;
texture->m_mip_levels = 1;
texture->m_type = PICCOLO_IMAGE_TYPE::PICCOLO_IMAGE_TYPE_2D;
Expand Down Expand Up @@ -121,12 +120,12 @@ namespace Piccolo
}

// index buffer
size_t index_size = bind_data->index_buffer.size() * sizeof(uint16_t);
size_t index_size = bind_data->index_buffer.size() * sizeof(uint32_t);
ret.m_static_mesh_data.m_index_buffer = std::make_shared<BufferData>(index_size);
uint16_t* index = (uint16_t*)ret.m_static_mesh_data.m_index_buffer->m_data;
uint32_t* index = (uint32_t*)ret.m_static_mesh_data.m_index_buffer->m_data;
for (size_t i = 0; i < bind_data->index_buffer.size(); i++)
{
index[i] = static_cast<uint16_t>(bind_data->index_buffer[i]);
index[i] = static_cast<uint32_t>(bind_data->index_buffer[i]);
}

// skeleton binding buffer
Expand Down Expand Up @@ -325,17 +324,17 @@ namespace Piccolo

uint32_t stride = sizeof(MeshVertexDataDefinition);
mesh_data.m_vertex_buffer = std::make_shared<BufferData>(mesh_vertices.size() * stride);
mesh_data.m_index_buffer = std::make_shared<BufferData>(mesh_vertices.size() * sizeof(uint16_t));
mesh_data.m_index_buffer = std::make_shared<BufferData>(mesh_vertices.size() * sizeof(uint32_t));

assert(mesh_vertices.size() <= std::numeric_limits<uint16_t>::max()); // take care of the index range, should be
assert(mesh_vertices.size() <= std::numeric_limits<uint32_t>::max()); // take care of the index range, should be
// consistent with the index range used by
// vulkan

uint16_t* indices = (uint16_t*)mesh_data.m_index_buffer->m_data;
uint32_t* indices = (uint32_t*)mesh_data.m_index_buffer->m_data;
for (size_t i = 0; i < mesh_vertices.size(); i++)
{
((MeshVertexDataDefinition*)(mesh_data.m_vertex_buffer->m_data))[i] = mesh_vertices[i];
indices[i] = static_cast<uint16_t>(i);
indices[i] = static_cast<uint32_t>(i);
}

return mesh_data;
Expand Down
Loading