detached c9165de

fix(vulkan): bind exact blend pixel and draw table ranges

commit
c9165de893f9367d7a0ba234a3490155438e3f4a
author
brice · · 2026-09-26 09:29 UTC
parent
4121259
signature
GPG VerifiedCD88F9E564E0102646FB6077A1A07C7C7C3E349D · arch-gpg Verified for the committer email
2 files · +7 -6
M internal/adapters/vulkan/blend.go +5 -5
@@ -132,12 +132,12 @@ func (r *Renderer) destroyBlend() {
132132 *b = blendPipeline{}
133133 }
134134
135-// bindStaging points the set at the staging buffer: blended pixels in
136-// [0, tableOffset), the draw table from tableOffset.
137-func (r *Renderer) bindStaging(tableOffset int) {
135+// bindStaging points the set at the staging buffer: pixels blended
136+// pixel bytes from 0, and the draw table of n entries at tableOffset.
137+func (r *Renderer) bindStaging(pixels, tableOffset, n int) {
138138 infos := []vk.DescriptorBufferInfo{
139- {Buffer: r.staging, Range: vk.DeviceSize(max(tableOffset, 4))},
140- {Buffer: r.staging, Offset: vk.DeviceSize(tableOffset), Range: wholeSize},
139+ {Buffer: r.staging, Range: vk.DeviceSize(max(pixels, 4))},
140+ {Buffer: r.staging, Offset: vk.DeviceSize(tableOffset), Range: vk.DeviceSize(n * drawSize)},
141141 }
142142 writes := []vk.WriteDescriptorSet{
143143 {SType: vk.StructureTypeWriteDescriptorSet, DstSet: r.blend.set, DstBinding: 0, DescriptorCount: 1, DescriptorType: vk.DescriptorTypeStorageBuffer, BufferInfo: &infos[0]},
@@ -132,12 +132,12 @@ func (r *Renderer) destroyBlend() {
132 *b = blendPipeline{}132 *b = blendPipeline{}
133 }133 }
134 134
135-// bindStaging points the set at the staging buffer: blended pixels in135+// bindStaging points the set at the staging buffer: pixels blended
136-// [0, tableOffset), the draw table from tableOffset.136+// pixel bytes from 0, and the draw table of n entries at tableOffset.
137-func (r *Renderer) bindStaging(tableOffset int) {137+func (r *Renderer) bindStaging(pixels, tableOffset, n int) {
138 infos := []vk.DescriptorBufferInfo{138 infos := []vk.DescriptorBufferInfo{
139- {Buffer: r.staging, Range: vk.DeviceSize(max(tableOffset, 4))},139+ {Buffer: r.staging, Range: vk.DeviceSize(max(pixels, 4))},
140- {Buffer: r.staging, Offset: vk.DeviceSize(tableOffset), Range: wholeSize},140+ {Buffer: r.staging, Offset: vk.DeviceSize(tableOffset), Range: vk.DeviceSize(n * drawSize)},
141 }141 }
142 writes := []vk.WriteDescriptorSet{142 writes := []vk.WriteDescriptorSet{
143 {SType: vk.StructureTypeWriteDescriptorSet, DstSet: r.blend.set, DstBinding: 0, DescriptorCount: 1, DescriptorType: vk.DescriptorTypeStorageBuffer, BufferInfo: &infos[0]},143 {SType: vk.StructureTypeWriteDescriptorSet, DstSet: r.blend.set, DstBinding: 0, DescriptorCount: 1, DescriptorType: vk.DescriptorTypeStorageBuffer, BufferInfo: &infos[0]},
M internal/adapters/vulkan/renderer.go +2 -1
@@ -598,6 +598,7 @@ func (r *Renderer) Render(s ports.Scene, contents map[ports.WindowID]ports.Surfa
598598 blends++
599599 }
600600 }
601+ pixelBytes := used
601602 tableOffset := (used + r.align - 1) / r.align * r.align
602603 used = tableOffset + blends*drawSize
603604 for k := range uploads {
@@ -611,7 +612,7 @@ func (r *Renderer) Render(s ports.Scene, contents map[ports.WindowID]ports.Surfa
611612 }
612613 data := unsafe.Slice((*byte)(r.stagingMapped), r.stagingSize)
613614 if blends > 0 {
614- r.bindStaging(tableOffset)
615+ r.bindStaging(pixelBytes, tableOffset, blends)
615616 i := 0
616617 for k := range uploads {
617618 if uploads[k].blend {
@@ -598,6 +598,7 @@ func (r *Renderer) Render(s ports.Scene, contents map[ports.WindowID]ports.Surfa
598 blends++598 blends++
599 }599 }
600 }600 }
601+ pixelBytes := used
601 tableOffset := (used + r.align - 1) / r.align * r.align602 tableOffset := (used + r.align - 1) / r.align * r.align
602 used = tableOffset + blends*drawSize603 used = tableOffset + blends*drawSize
603 for k := range uploads {604 for k := range uploads {
@@ -611,7 +612,7 @@ func (r *Renderer) Render(s ports.Scene, contents map[ports.WindowID]ports.Surfa
611 }612 }
612 data := unsafe.Slice((*byte)(r.stagingMapped), r.stagingSize)613 data := unsafe.Slice((*byte)(r.stagingMapped), r.stagingSize)
613 if blends > 0 {614 if blends > 0 {
614- r.bindStaging(tableOffset)615+ r.bindStaging(pixelBytes, tableOffset, blends)
615 i := 0616 i := 0
616 for k := range uploads {617 for k := range uploads {
617 if uploads[k].blend {618 if uploads[k].blend {

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 26

Tags 10

↑↓ moveenter openesc close