vk_rasterizer: Properly set fixed attrib offset
* There was a small chance the main attrib exactly fit the buffer which caused the fixed offset to be 0x8000000 and crash
This commit is contained in:
@ -77,7 +77,9 @@ TextureRuntime::TextureRuntime(Driver& driver)
|
||||
|
||||
StagingData TextureRuntime::FindStaging(u32 size, bool upload) {
|
||||
if (!upload) {
|
||||
ASSERT_MSG(download_buffer.size() <= size, "Download buffer to small");
|
||||
if (size > download_buffer.size()) {
|
||||
download_buffer.resize(size);
|
||||
}
|
||||
return StagingData{
|
||||
.size = size,
|
||||
.mapped = std::span{download_buffer.data(), size},
|
||||
|
@ -714,7 +714,7 @@ void RendererVulkan::DrawSingleScreen(u32 screen_id, float x, float y, float w,
|
||||
draw_info.i_resolution =
|
||||
Common::Vec4f{width * scale_factor, height * scale_factor, 1.0f / (width * scale_factor),
|
||||
1.0f / (height * scale_factor)};
|
||||
draw_info.o_resolution = Common::Vec4f{h, w, 1.0f / h, 1.0f / w};
|
||||
draw_info.o_resolution = Common::Vec4f{w, h, 1.0f / h, 1.0f / w};
|
||||
draw_info.screen_id_l = screen_id;
|
||||
|
||||
scheduler.Record([this, offset = offset, info = draw_info](vk::CommandBuffer cmdbuf) {
|
||||
@ -841,7 +841,8 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout&
|
||||
if (layout.top_screen_enabled) {
|
||||
if (layout.is_rotated) {
|
||||
if (render_3d == Settings::StereoRenderOption::Off) {
|
||||
DrawSingleScreenRotated(0, top_screen.left, top_screen.top, top_screen.GetWidth(),
|
||||
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
||||
DrawSingleScreenRotated(eye, top_screen.left, top_screen.top, top_screen.GetWidth(),
|
||||
top_screen.GetHeight());
|
||||
} else if (render_3d == Settings::StereoRenderOption::SideBySide) {
|
||||
DrawSingleScreenRotated(0, (float)top_screen.left / 2, (float)top_screen.top,
|
||||
@ -867,7 +868,8 @@ void RendererVulkan::DrawScreens(Frame* frame, const Layout::FramebufferLayout&
|
||||
}
|
||||
} else {
|
||||
if (render_3d == Settings::StereoRenderOption::Off) {
|
||||
DrawSingleScreen(0, (float)top_screen.left, (float)top_screen.top,
|
||||
int eye = static_cast<int>(Settings::values.mono_render_option.GetValue());
|
||||
DrawSingleScreen(eye, (float)top_screen.left, (float)top_screen.top,
|
||||
(float)top_screen.GetWidth(), (float)top_screen.GetHeight());
|
||||
} else if (render_3d == Settings::StereoRenderOption::SideBySide) {
|
||||
DrawSingleScreen(0, (float)top_screen.left / 2, (float)top_screen.top,
|
||||
|
@ -267,7 +267,6 @@ void RasterizerVulkan::SetupVertexArray(u32 vs_input_size, u32 vs_input_index_mi
|
||||
buffer_offset += Common::AlignUp(aligned_stride * vertex_num, 4);
|
||||
}
|
||||
|
||||
binding_offsets[layout.binding_count] = array_offset + buffer_offset;
|
||||
stream_buffer.Commit(buffer_offset);
|
||||
|
||||
// Assign the rest of the attributes to the last binding
|
||||
@ -276,9 +275,6 @@ void RasterizerVulkan::SetupVertexArray(u32 vs_input_size, u32 vs_input_index_mi
|
||||
// Bind the generated bindings
|
||||
scheduler.Record([this, binding_count = layout.binding_count,
|
||||
vertex_offsets = binding_offsets](vk::CommandBuffer cmdbuf) {
|
||||
for (auto& offset : vertex_offsets) {
|
||||
ASSERT_MSG(offset != 0x8000000, "Bad offset");
|
||||
}
|
||||
cmdbuf.bindVertexBuffers(0, binding_count, vertex_buffers.data(), vertex_offsets.data());
|
||||
});
|
||||
}
|
||||
@ -289,6 +285,7 @@ void RasterizerVulkan::SetupFixedAttribs() {
|
||||
VertexLayout& layout = pipeline_info.vertex_layout;
|
||||
|
||||
auto [fixed_ptr, fixed_offset, _] = stream_buffer.Map(16 * sizeof(Common::Vec4f), 0);
|
||||
binding_offsets[layout.binding_count] = fixed_offset;
|
||||
|
||||
// Reserve the last binding for fixed and default attributes
|
||||
// Place the default attrib at offset zero for easy access
|
||||
|
Reference in New Issue
Block a user