mirror of
https://github.com/italicsjenga/vello.git
synced 2025-01-10 20:51:29 +11:00
macOS fixes
* Fix call to removed encoded_scene method in pgpu-render * Add new ImageFormat::Surface variant to select a pixel format that matches the platform specific surface format. This makes gradients consistent across platforms.
This commit is contained in:
parent
8ee317a922
commit
a6597af52a
|
@ -87,7 +87,7 @@ impl PgpuRenderer {
|
||||||
.session
|
.session
|
||||||
.image_from_raw_mtl(target, self.width, self.height);
|
.image_from_raw_mtl(target, self.width, self.height);
|
||||||
if let Some(renderer) = &mut self.pgpu_renderer {
|
if let Some(renderer) = &mut self.pgpu_renderer {
|
||||||
renderer.upload_scene(&scene.encoded_scene(), 0).unwrap();
|
renderer.upload_scene(&scene.0, 0).unwrap();
|
||||||
renderer.record(&mut cmd_buf, &self.query_pool, 0);
|
renderer.record(&mut cmd_buf, &self.query_pool, 0);
|
||||||
// TODO later: we can bind the destination image and avoid the copy.
|
// TODO later: we can bind the destination image and avoid the copy.
|
||||||
cmd_buf.blit_image(&renderer.image_dev, &dst_image);
|
cmd_buf.blit_image(&renderer.image_dev, &dst_image);
|
||||||
|
|
|
@ -330,7 +330,7 @@ impl crate::backend::Device for Dx12Device {
|
||||||
) -> Result<Self::Image, Error> {
|
) -> Result<Self::Image, Error> {
|
||||||
let format = match format {
|
let format = match format {
|
||||||
ImageFormat::A8 => winapi::shared::dxgiformat::DXGI_FORMAT_R8_UNORM,
|
ImageFormat::A8 => winapi::shared::dxgiformat::DXGI_FORMAT_R8_UNORM,
|
||||||
ImageFormat::Rgba8 => winapi::shared::dxgiformat::DXGI_FORMAT_R8G8B8A8_UNORM,
|
ImageFormat::Rgba8 | ImageFormat::Surface => winapi::shared::dxgiformat::DXGI_FORMAT_R8G8B8A8_UNORM,
|
||||||
};
|
};
|
||||||
let resource = self
|
let resource = self
|
||||||
.device
|
.device
|
||||||
|
|
|
@ -98,6 +98,8 @@ pub enum ImageFormat {
|
||||||
A8,
|
A8,
|
||||||
// 8 bit per pixel RGBA
|
// 8 bit per pixel RGBA
|
||||||
Rgba8,
|
Rgba8,
|
||||||
|
// Match default surface format
|
||||||
|
Surface,
|
||||||
}
|
}
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
|
|
|
@ -349,7 +349,8 @@ impl crate::backend::Device for MtlDevice {
|
||||||
//desc.set_mipmap_level_count(1);
|
//desc.set_mipmap_level_count(1);
|
||||||
let mtl_format = match format {
|
let mtl_format = match format {
|
||||||
ImageFormat::A8 => metal::MTLPixelFormat::R8Unorm,
|
ImageFormat::A8 => metal::MTLPixelFormat::R8Unorm,
|
||||||
ImageFormat::Rgba8 => metal::MTLPixelFormat::BGRA8Unorm,
|
ImageFormat::Rgba8 => metal::MTLPixelFormat::RGBA8Unorm,
|
||||||
|
ImageFormat::Surface => metal::MTLPixelFormat::BGRA8Unorm,
|
||||||
};
|
};
|
||||||
desc.set_pixel_format(mtl_format);
|
desc.set_pixel_format(mtl_format);
|
||||||
desc.set_usage(metal::MTLTextureUsage::ShaderRead | metal::MTLTextureUsage::ShaderWrite);
|
desc.set_usage(metal::MTLTextureUsage::ShaderRead | metal::MTLTextureUsage::ShaderWrite);
|
||||||
|
|
|
@ -578,7 +578,7 @@ impl crate::backend::Device for VkDevice {
|
||||||
| vk::ImageUsageFlags::TRANSFER_DST;
|
| vk::ImageUsageFlags::TRANSFER_DST;
|
||||||
let vk_format = match format {
|
let vk_format = match format {
|
||||||
ImageFormat::A8 => vk::Format::R8_UNORM,
|
ImageFormat::A8 => vk::Format::R8_UNORM,
|
||||||
ImageFormat::Rgba8 => vk::Format::R8G8B8A8_UNORM,
|
ImageFormat::Rgba8 | ImageFormat::Surface => vk::Format::R8G8B8A8_UNORM,
|
||||||
};
|
};
|
||||||
let image = device.create_image(
|
let image = device.create_image(
|
||||||
&vk::ImageCreateInfo::builder()
|
&vk::ImageCreateInfo::builder()
|
||||||
|
|
|
@ -224,7 +224,7 @@ impl Renderer {
|
||||||
|
|
||||||
let image_format = match config.format {
|
let image_format = match config.format {
|
||||||
PixelFormat::A8 => piet_gpu_hal::ImageFormat::A8,
|
PixelFormat::A8 => piet_gpu_hal::ImageFormat::A8,
|
||||||
PixelFormat::Rgba8 => piet_gpu_hal::ImageFormat::Rgba8,
|
PixelFormat::Rgba8 => piet_gpu_hal::ImageFormat::Surface,
|
||||||
};
|
};
|
||||||
let image_dev = session.create_image2d(width as u32, height as u32, image_format)?;
|
let image_dev = session.create_image2d(width as u32, height as u32, image_format)?;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue