зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1612941 - support variable depth buffer size in WR. r=gw
Differential Revision: https://phabricator.services.mozilla.com/D65602 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
efe93a2734
Коммит
a82ed1dd00
|
@ -322,6 +322,7 @@ impl CompositeState {
|
|||
compositor_kind: CompositorKind,
|
||||
mut picture_caching_is_enabled: bool,
|
||||
global_device_pixel_scale: DevicePixelScale,
|
||||
max_depth_ids: i32,
|
||||
) -> Self {
|
||||
// The native compositor interface requires picture caching to work, so
|
||||
// force it here and warn if it was disabled.
|
||||
|
@ -336,7 +337,7 @@ impl CompositeState {
|
|||
opaque_tiles: Vec::new(),
|
||||
alpha_tiles: Vec::new(),
|
||||
clear_tiles: Vec::new(),
|
||||
z_generator: ZBufferIdGenerator::new(0),
|
||||
z_generator: ZBufferIdGenerator::new(0, max_depth_ids),
|
||||
dirty_rects_are_valid: true,
|
||||
compositor_kind,
|
||||
picture_caching_is_enabled,
|
||||
|
|
|
@ -8,7 +8,7 @@ use crate::debug_font_data;
|
|||
use crate::device::{Device, Program, Texture, TextureSlot, VertexDescriptor, ShaderError, VAO};
|
||||
use crate::device::{TextureFilter, VertexAttribute, VertexAttributeKind, VertexUsageHint};
|
||||
use euclid::{Point2D, Rect, Size2D, Transform3D, default};
|
||||
use crate::internal_types::{ORTHO_FAR_PLANE, ORTHO_NEAR_PLANE, Swizzle};
|
||||
use crate::internal_types::Swizzle;
|
||||
use std::f32;
|
||||
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
|
@ -333,8 +333,8 @@ impl DebugRenderer {
|
|||
viewport_size.width as f32 * scale,
|
||||
bottom,
|
||||
top,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
device.ortho_near_plane(),
|
||||
device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
// Triangles
|
||||
|
|
|
@ -1034,6 +1034,11 @@ enum TexStorageUsage {
|
|||
Always,
|
||||
}
|
||||
|
||||
// We get 24 bits of Z value - use up 22 bits of it to give us
|
||||
// 4 bits to account for GPU issues. This seems to manifest on
|
||||
// some GPUs under certain perspectives due to z interpolation
|
||||
// precision problems.
|
||||
const RESERVE_DEPTH_BITS: i32 = 2;
|
||||
|
||||
pub struct Device {
|
||||
gl: Rc<dyn gl::Gl>,
|
||||
|
@ -1064,6 +1069,7 @@ pub struct Device {
|
|||
color_formats: TextureFormatPair<ImageFormat>,
|
||||
bgra_formats: TextureFormatPair<gl::GLuint>,
|
||||
swizzle_settings: SwizzleSettings,
|
||||
depth_format: gl::GLuint,
|
||||
|
||||
/// Map from texture dimensions to shared depth buffers for render targets.
|
||||
///
|
||||
|
@ -1471,8 +1477,14 @@ impl Device {
|
|||
),
|
||||
};
|
||||
|
||||
info!("GL texture cache {:?}, bgra {:?} swizzle {:?}, texture storage {:?}",
|
||||
color_formats, bgra_formats, bgra8_sampling_swizzle, texture_storage_usage);
|
||||
let depth_format = if renderer_name.starts_with("Software WebRender") {
|
||||
gl::DEPTH_COMPONENT16
|
||||
} else {
|
||||
gl::DEPTH_COMPONENT24
|
||||
};
|
||||
|
||||
info!("GL texture cache {:?}, bgra {:?} swizzle {:?}, texture storage {:?}, depth {:?}",
|
||||
color_formats, bgra_formats, bgra8_sampling_swizzle, texture_storage_usage, depth_format);
|
||||
let supports_copy_image_sub_data = supports_extension(&extensions, "GL_EXT_copy_image") ||
|
||||
supports_extension(&extensions, "GL_ARB_copy_image");
|
||||
|
||||
|
@ -1544,6 +1556,7 @@ impl Device {
|
|||
swizzle_settings: SwizzleSettings {
|
||||
bgra8_sampling_swizzle,
|
||||
},
|
||||
depth_format,
|
||||
|
||||
depth_targets: FastHashMap::default(),
|
||||
|
||||
|
@ -1624,6 +1637,28 @@ impl Device {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn depth_bits(&self) -> i32 {
|
||||
match self.depth_format {
|
||||
gl::DEPTH_COMPONENT16 => 16,
|
||||
gl::DEPTH_COMPONENT24 => 24,
|
||||
_ => panic!("Unknown depth format {:?}", self.depth_format),
|
||||
}
|
||||
}
|
||||
|
||||
// See gpu_types.rs where we declare the number of possible documents and
|
||||
// number of items per document. This should match up with that.
|
||||
pub fn max_depth_ids(&self) -> i32 {
|
||||
return 1 << (self.depth_bits() - RESERVE_DEPTH_BITS);
|
||||
}
|
||||
|
||||
pub fn ortho_near_plane(&self) -> f32 {
|
||||
return -self.max_depth_ids() as f32;
|
||||
}
|
||||
|
||||
pub fn ortho_far_plane(&self) -> f32 {
|
||||
return (self.max_depth_ids() - 1) as f32;
|
||||
}
|
||||
|
||||
pub fn optimal_pbo_stride(&self) -> NonZeroUsize {
|
||||
self.optimal_pbo_stride
|
||||
}
|
||||
|
@ -2420,13 +2455,14 @@ impl Device {
|
|||
|
||||
fn acquire_depth_target(&mut self, dimensions: DeviceIntSize) -> RBOId {
|
||||
let gl = &self.gl;
|
||||
let depth_format = self.depth_format;
|
||||
let target = self.depth_targets.entry(dimensions).or_insert_with(|| {
|
||||
let renderbuffer_ids = gl.gen_renderbuffers(1);
|
||||
let depth_rb = renderbuffer_ids[0];
|
||||
gl.bind_renderbuffer(gl::RENDERBUFFER, depth_rb);
|
||||
gl.renderbuffer_storage(
|
||||
gl::RENDERBUFFER,
|
||||
gl::DEPTH_COMPONENT24,
|
||||
depth_format,
|
||||
dimensions.width as _,
|
||||
dimensions.height as _,
|
||||
);
|
||||
|
|
|
@ -66,6 +66,7 @@ pub struct FrameBuilderConfig {
|
|||
pub background_color: Option<ColorF>,
|
||||
pub compositor_kind: CompositorKind,
|
||||
pub tile_size_override: Option<DeviceIntSize>,
|
||||
pub max_depth_ids: i32,
|
||||
}
|
||||
|
||||
/// A set of common / global resources that are retained between
|
||||
|
@ -569,6 +570,7 @@ impl FrameBuilder {
|
|||
scene.config.compositor_kind,
|
||||
picture_caching_is_enabled,
|
||||
global_device_pixel_scale,
|
||||
scene.config.max_depth_ids,
|
||||
);
|
||||
|
||||
let main_render_task_id = self.build_layer_screen_rects_and_cull_layers(
|
||||
|
@ -605,7 +607,7 @@ impl FrameBuilder {
|
|||
);
|
||||
|
||||
// Used to generated a unique z-buffer value per primitive.
|
||||
let mut z_generator = ZBufferIdGenerator::new(layer);
|
||||
let mut z_generator = ZBufferIdGenerator::new(layer, scene.config.max_depth_ids);
|
||||
let use_dual_source_blending = scene.config.dual_source_blending_is_enabled &&
|
||||
scene.config.dual_source_blending_is_supported;
|
||||
|
||||
|
|
|
@ -25,12 +25,7 @@ pub const VECS_PER_TRANSFORM: usize = 8;
|
|||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
pub struct ZBufferId(pub i32);
|
||||
|
||||
// We get 24 bits of Z value - use up 22 bits of it to give us
|
||||
// 4 bits to account for GPU issues. This seems to manifest on
|
||||
// some GPUs under certain perspectives due to z interpolation
|
||||
// precision problems.
|
||||
const MAX_DOCUMENT_LAYERS : i8 = 1 << 3;
|
||||
const MAX_ITEMS_PER_DOCUMENT_LAYER : i32 = 1 << 19;
|
||||
const MAX_DOCUMENT_LAYER_VALUE : i8 = MAX_DOCUMENT_LAYERS / 2 - 1;
|
||||
const MIN_DOCUMENT_LAYER_VALUE : i8 = -MAX_DOCUMENT_LAYERS / 2;
|
||||
|
||||
|
@ -46,20 +41,23 @@ impl ZBufferId {
|
|||
pub struct ZBufferIdGenerator {
|
||||
base: i32,
|
||||
next: i32,
|
||||
max_items_per_document_layer: i32,
|
||||
}
|
||||
|
||||
impl ZBufferIdGenerator {
|
||||
pub fn new(layer: DocumentLayer) -> Self {
|
||||
pub fn new(layer: DocumentLayer, max_depth_ids: i32) -> Self {
|
||||
debug_assert!(layer >= MIN_DOCUMENT_LAYER_VALUE);
|
||||
debug_assert!(layer <= MAX_DOCUMENT_LAYER_VALUE);
|
||||
let max_items_per_document_layer = max_depth_ids / MAX_DOCUMENT_LAYERS as i32;
|
||||
ZBufferIdGenerator {
|
||||
base: layer as i32 * MAX_ITEMS_PER_DOCUMENT_LAYER,
|
||||
next: 0
|
||||
base: layer as i32 * max_items_per_document_layer,
|
||||
next: 0,
|
||||
max_items_per_document_layer,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn next(&mut self) -> ZBufferId {
|
||||
debug_assert!(self.next < MAX_ITEMS_PER_DOCUMENT_LAYER);
|
||||
debug_assert!(self.next < self.max_items_per_document_layer);
|
||||
let id = ZBufferId(self.next + self.base);
|
||||
self.next += 1;
|
||||
id
|
||||
|
|
|
@ -299,11 +299,6 @@ pub enum TextureSource {
|
|||
Dummy,
|
||||
}
|
||||
|
||||
// See gpu_types.rs where we declare the number of possible documents and
|
||||
// number of items per document. This should match up with that.
|
||||
pub const ORTHO_NEAR_PLANE: f32 = -(1 << 22) as f32;
|
||||
pub const ORTHO_FAR_PLANE: f32 = ((1 << 22) - 1) as f32;
|
||||
|
||||
#[derive(Copy, Clone, Debug, PartialEq)]
|
||||
#[cfg_attr(feature = "capture", derive(Serialize))]
|
||||
#[cfg_attr(feature = "replay", derive(Deserialize))]
|
||||
|
|
|
@ -69,7 +69,7 @@ use crate::gpu_cache::{GpuBlockData, GpuCacheUpdate, GpuCacheUpdateList};
|
|||
use crate::gpu_cache::{GpuCacheDebugChunk, GpuCacheDebugCmd};
|
||||
use crate::gpu_types::{PrimitiveHeaderI, PrimitiveHeaderF, ScalingInstance, SvgFilterInstance, TransformData};
|
||||
use crate::gpu_types::{CompositeInstance, ResolveInstanceData, ZBufferId};
|
||||
use crate::internal_types::{TextureSource, ORTHO_FAR_PLANE, ORTHO_NEAR_PLANE, ResourceCacheError};
|
||||
use crate::internal_types::{TextureSource, ResourceCacheError};
|
||||
use crate::internal_types::{CacheTextureId, DebugOutput, FastHashMap, FastHashSet, LayerIndex, RenderedDocument, ResultMsg};
|
||||
use crate::internal_types::{TextureCacheAllocationKind, TextureCacheUpdate, TextureUpdateList, TextureUpdateSource};
|
||||
use crate::internal_types::{RenderTargetInfo, SavedTargetIndex, Swizzle};
|
||||
|
@ -2268,6 +2268,7 @@ impl Renderer {
|
|||
background_color: options.clear_color,
|
||||
compositor_kind,
|
||||
tile_size_override: None,
|
||||
max_depth_ids: device.max_depth_ids(),
|
||||
};
|
||||
info!("WR {:?}", config);
|
||||
|
||||
|
@ -4341,8 +4342,8 @@ impl Renderer {
|
|||
surface_size.width as f32,
|
||||
0.0,
|
||||
surface_size.height as f32,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
// Bind an appropriate YUV shader for the texture format kind
|
||||
|
@ -5124,8 +5125,8 @@ impl Renderer {
|
|||
target_size.width as f32,
|
||||
0.0,
|
||||
target_size.height as f32,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
)
|
||||
};
|
||||
|
||||
|
@ -5586,8 +5587,8 @@ impl Renderer {
|
|||
offset.x + size.width,
|
||||
bottom,
|
||||
top,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
let fb_scale = Scale::<_, _, FramebufferPixel>::new(1i32);
|
||||
|
@ -5724,8 +5725,8 @@ impl Renderer {
|
|||
draw_target.dimensions().width as f32,
|
||||
0.0,
|
||||
draw_target.dimensions().height as f32,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
self.draw_picture_cache_target(
|
||||
|
@ -5765,8 +5766,8 @@ impl Renderer {
|
|||
draw_target.dimensions().width as f32,
|
||||
0.0,
|
||||
draw_target.dimensions().height as f32,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
self.draw_alpha_target(
|
||||
|
@ -5791,8 +5792,8 @@ impl Renderer {
|
|||
draw_target.dimensions().width as f32,
|
||||
0.0,
|
||||
draw_target.dimensions().height as f32,
|
||||
ORTHO_NEAR_PLANE,
|
||||
ORTHO_FAR_PLANE,
|
||||
self.device.ortho_near_plane(),
|
||||
self.device.ortho_far_plane(),
|
||||
);
|
||||
|
||||
let clear_depth = if target.needs_depth() {
|
||||
|
|
|
@ -296,6 +296,7 @@ impl BuiltScene {
|
|||
background_color: None,
|
||||
compositor_kind: CompositorKind::default(),
|
||||
tile_size_override: None,
|
||||
max_depth_ids: 0,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче