зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1883336 - Make patterns work for composited quads. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D204773
This commit is contained in:
Родитель
c099b03ec7
Коммит
8b5800820d
|
@ -518,7 +518,7 @@ fn add_composite_prim(
|
|||
|
||||
frame_state.push_cmd(
|
||||
&PrimitiveCommand::quad(
|
||||
pattern.kind,
|
||||
PatternKind::ColorOrTexture,
|
||||
pattern.shader_input,
|
||||
prim_instance_index,
|
||||
composite_prim_address,
|
||||
|
|
|
@ -211,6 +211,7 @@ impl<T: RenderTarget> RenderTargetList<T> {
|
|||
}
|
||||
}
|
||||
|
||||
const NUM_PATTERNS: usize = crate::pattern::NUM_PATTERNS as usize;
|
||||
|
||||
/// Contains the work (in the form of instance arrays) needed to fill a color
|
||||
/// color output surface (RGBA8).
|
||||
|
@ -236,9 +237,9 @@ pub struct ColorRenderTarget {
|
|||
pub resolve_ops: Vec<ResolveOp>,
|
||||
pub clear_color: Option<ColorF>,
|
||||
|
||||
pub prim_instances: Vec<PrimitiveInstanceData>,
|
||||
pub prim_instances_with_scissor: FastHashMap<DeviceIntRect, Vec<PrimitiveInstanceData>>,
|
||||
|
||||
pub prim_instances: [Vec<PrimitiveInstanceData>; NUM_PATTERNS],
|
||||
pub prim_instances_with_scissor: FastHashMap<(DeviceIntRect, PatternKind), Vec<PrimitiveInstanceData>>,
|
||||
|
||||
pub clip_masks: ClipMaskInstanceList,
|
||||
}
|
||||
|
||||
|
@ -262,7 +263,7 @@ impl RenderTarget for ColorRenderTarget {
|
|||
used_rect,
|
||||
resolve_ops: Vec::new(),
|
||||
clear_color: Some(ColorF::TRANSPARENT),
|
||||
prim_instances: Vec::new(),
|
||||
prim_instances: [Vec::new(), Vec::new()],
|
||||
prim_instances_with_scissor: FastHashMap::default(),
|
||||
clip_masks: ClipMaskInstanceList::new(),
|
||||
}
|
||||
|
@ -393,11 +394,11 @@ impl RenderTarget for ColorRenderTarget {
|
|||
|_, instance| {
|
||||
if info.prim_needs_scissor_rect {
|
||||
self.prim_instances_with_scissor
|
||||
.entry(target_rect)
|
||||
.entry((target_rect, info.pattern))
|
||||
.or_insert(Vec::new())
|
||||
.push(instance);
|
||||
} else {
|
||||
self.prim_instances.push(instance);
|
||||
self.prim_instances[info.pattern as usize].push(instance);
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -2173,8 +2173,8 @@ impl Renderer {
|
|||
fn handle_prims(
|
||||
&mut self,
|
||||
draw_target: &DrawTarget,
|
||||
prim_instances: &[PrimitiveInstanceData],
|
||||
prim_instances_with_scissor: &FastHashMap<DeviceIntRect, Vec<PrimitiveInstanceData>>,
|
||||
prim_instances: &[Vec<PrimitiveInstanceData>],
|
||||
prim_instances_with_scissor: &FastHashMap<(DeviceIntRect, PatternKind), Vec<PrimitiveInstanceData>>,
|
||||
projection: &default::Transform3D<f32>,
|
||||
stats: &mut RendererStats,
|
||||
) {
|
||||
|
@ -2183,10 +2183,17 @@ impl Renderer {
|
|||
{
|
||||
let _timer = self.gpu_profiler.start_timer(GPU_TAG_INDIRECT_PRIM);
|
||||
|
||||
if !prim_instances.is_empty() {
|
||||
if prim_instances.iter().any(|instances| !instances.is_empty()) {
|
||||
self.set_blend(false, FramebufferKind::Other);
|
||||
}
|
||||
|
||||
self.shaders.borrow_mut().ps_quad_textured.bind(
|
||||
for (pattern_idx, prim_instances) in prim_instances.iter().enumerate() {
|
||||
if prim_instances.is_empty() {
|
||||
continue;
|
||||
}
|
||||
let pattern = PatternKind::from_u32(pattern_idx as u32);
|
||||
|
||||
self.shaders.borrow_mut().get_quad_shader(pattern).bind(
|
||||
&mut self.device,
|
||||
projection,
|
||||
None,
|
||||
|
@ -2194,10 +2201,13 @@ impl Renderer {
|
|||
&mut self.profile,
|
||||
);
|
||||
|
||||
// TODO: Some patterns will need to be able to sample textures.
|
||||
let texture_bindings = BatchTextures::empty();
|
||||
|
||||
self.draw_instanced_batch(
|
||||
prim_instances,
|
||||
VertexArrayKind::Primitive,
|
||||
&BatchTextures::empty(),
|
||||
&texture_bindings,
|
||||
stats,
|
||||
);
|
||||
}
|
||||
|
@ -2207,17 +2217,22 @@ impl Renderer {
|
|||
self.device.set_blend_mode_premultiplied_alpha();
|
||||
self.device.enable_scissor();
|
||||
|
||||
self.shaders.borrow_mut().ps_quad_textured.bind(
|
||||
&mut self.device,
|
||||
projection,
|
||||
None,
|
||||
&mut self.renderer_errors,
|
||||
&mut self.profile,
|
||||
);
|
||||
let mut prev_pattern = None;
|
||||
|
||||
for ((scissor_rect, pattern), prim_instances) in prim_instances_with_scissor {
|
||||
if prev_pattern != Some(*pattern) {
|
||||
prev_pattern = Some(*pattern);
|
||||
self.shaders.borrow_mut().get_quad_shader(*pattern).bind(
|
||||
&mut self.device,
|
||||
projection,
|
||||
None,
|
||||
&mut self.renderer_errors,
|
||||
&mut self.profile,
|
||||
);
|
||||
}
|
||||
|
||||
for (scissor_rect, prim_instances) in prim_instances_with_scissor {
|
||||
self.device.set_scissor_rect(draw_target.to_framebuffer_rect(*scissor_rect));
|
||||
|
||||
// TODO: hook up the right pattern.
|
||||
self.draw_instanced_batch(
|
||||
prim_instances,
|
||||
VertexArrayKind::Primitive,
|
||||
|
|
|
@ -1154,6 +1154,16 @@ impl Shaders {
|
|||
.expect("bug: unsupported scale shader requested")
|
||||
}
|
||||
|
||||
pub fn get_quad_shader(
|
||||
&mut self,
|
||||
pattern: PatternKind
|
||||
) -> &mut LazilyCompiledShader {
|
||||
match pattern {
|
||||
PatternKind::ColorOrTexture => &mut self.ps_quad_textured,
|
||||
PatternKind::Mask => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get(&
|
||||
mut self,
|
||||
key: &BatchKey,
|
||||
|
|
Загрузка…
Ссылка в новой задаче