vulkan: sort ops by type
This commit is contained in:
parent
db4ff00330
commit
c83e3ffa4d
1 changed files with 27 additions and 3 deletions
|
|
@ -158,6 +158,7 @@ pub(super) struct Memory {
|
||||||
regions_1: Vec<Rect>,
|
regions_1: Vec<Rect>,
|
||||||
regions_2: Vec<Rect<u32>>,
|
regions_2: Vec<Rect<u32>>,
|
||||||
ops: StaticMap<RenderPass, Vec<VulkanOp>>,
|
ops: StaticMap<RenderPass, Vec<VulkanOp>>,
|
||||||
|
ops_tmp: StaticMap<RenderPass, Vec<VulkanOp>>,
|
||||||
fill_targets: Vec<Point>,
|
fill_targets: Vec<Point>,
|
||||||
tex_targets: Vec<[Point; 2]>,
|
tex_targets: Vec<[Point; 2]>,
|
||||||
}
|
}
|
||||||
|
|
@ -466,12 +467,34 @@ impl VulkanRenderer {
|
||||||
for ops in memory.ops.values_mut() {
|
for ops in memory.ops.values_mut() {
|
||||||
ops.clear();
|
ops.clear();
|
||||||
}
|
}
|
||||||
|
for ops in memory.ops_tmp.values_mut() {
|
||||||
|
ops.clear();
|
||||||
|
}
|
||||||
memory.tex_targets.clear();
|
memory.tex_targets.clear();
|
||||||
memory.fill_targets.clear();
|
memory.fill_targets.clear();
|
||||||
|
let sync = |memory: &mut Memory| {
|
||||||
|
for pass in RenderPass::variants() {
|
||||||
|
let ops = &mut memory.ops_tmp[pass];
|
||||||
|
ops.sort_unstable_by_key(|o| {
|
||||||
|
#[derive(Eq, PartialEq, PartialOrd, Ord)]
|
||||||
|
enum Key {
|
||||||
|
Fill { color: [u32; 4] },
|
||||||
|
Tex,
|
||||||
|
}
|
||||||
|
match o {
|
||||||
|
VulkanOp::Fill(f) => Key::Fill {
|
||||||
|
color: f.color.map(|c| c.to_bits()),
|
||||||
|
},
|
||||||
|
VulkanOp::Tex(_) => Key::Tex,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
memory.ops[pass].append(ops);
|
||||||
|
}
|
||||||
|
};
|
||||||
for op in opts {
|
for op in opts {
|
||||||
match op {
|
match op {
|
||||||
GfxApiOpt::Sync => {
|
GfxApiOpt::Sync => {
|
||||||
// nothing
|
sync(memory);
|
||||||
}
|
}
|
||||||
GfxApiOpt::FillRect(fr) => {
|
GfxApiOpt::FillRect(fr) => {
|
||||||
let target = fr.rect.to_points();
|
let target = fr.rect.to_points();
|
||||||
|
|
@ -480,7 +503,7 @@ impl VulkanRenderer {
|
||||||
RenderPass::BlendBuffer => TransferFunction::Linear,
|
RenderPass::BlendBuffer => TransferFunction::Linear,
|
||||||
RenderPass::FrameBuffer => TransferFunction::Srgb,
|
RenderPass::FrameBuffer => TransferFunction::Srgb,
|
||||||
};
|
};
|
||||||
let ops = &mut memory.ops[pass];
|
let ops = &mut memory.ops_tmp[pass];
|
||||||
let lo = memory.fill_targets.len();
|
let lo = memory.fill_targets.len();
|
||||||
for region in &memory.paint_regions[pass] {
|
for region in &memory.paint_regions[pass] {
|
||||||
let mut target = target;
|
let mut target = target;
|
||||||
|
|
@ -519,7 +542,7 @@ impl VulkanRenderer {
|
||||||
let target = ct.target.to_points();
|
let target = ct.target.to_points();
|
||||||
let source = ct.source.to_points();
|
let source = ct.source.to_points();
|
||||||
for pass in RenderPass::variants() {
|
for pass in RenderPass::variants() {
|
||||||
let ops = &mut memory.ops[pass];
|
let ops = &mut memory.ops_tmp[pass];
|
||||||
let lo = memory.tex_targets.len();
|
let lo = memory.tex_targets.len();
|
||||||
for region in &memory.paint_regions[pass] {
|
for region in &memory.paint_regions[pass] {
|
||||||
let mut target = target;
|
let mut target = target;
|
||||||
|
|
@ -555,6 +578,7 @@ impl VulkanRenderer {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sync(memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn collect_memory(&self) {
|
fn collect_memory(&self) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue