Skip to content

Commit

Permalink
Make queue reference immutable in draw API
Browse files Browse the repository at this point in the history
  • Loading branch information
pimlu committed Jan 31, 2022
1 parent c82ee04 commit 0506b88
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 21 deletions.
6 changes: 3 additions & 3 deletions examples/clipping.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let surface = unsafe { instance.create_surface(&window) };

// Initialize GPU
let (device, mut queue) = futures::executor::block_on(async {
let (device, queue) = futures::executor::block_on(async {
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
Expand Down Expand Up @@ -136,7 +136,7 @@ fn main() -> Result<(), Box<dyn Error>> {
glyph_brush
.draw_queued(
&device,
&mut queue,
&queue,
&mut encoder,
view,
size.width,
Expand All @@ -157,7 +157,7 @@ fn main() -> Result<(), Box<dyn Error>> {
glyph_brush
.draw_queued_with_transform_and_scissoring(
&device,
&mut queue,
&queue,
&mut encoder,
view,
wgpu_glyph::orthographic_projection(
Expand Down
4 changes: 2 additions & 2 deletions examples/depth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let surface = unsafe { instance.create_surface(&window) };

// Initialize GPU
let (device, mut queue) = futures::executor::block_on(async {
let (device, queue) = futures::executor::block_on(async {
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
Expand Down Expand Up @@ -151,7 +151,7 @@ fn main() -> Result<(), Box<dyn Error>> {
glyph_brush
.draw_queued(
&device,
&mut queue,
&queue,
&mut encoder,
view,
wgpu::RenderPassDepthStencilAttachment {
Expand Down
4 changes: 2 additions & 2 deletions examples/hello.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ fn main() -> Result<(), Box<dyn Error>> {
let surface = unsafe { instance.create_surface(&window) };

// Initialize GPU
let (device, mut queue) = futures::executor::block_on(async {
let (device, queue) = futures::executor::block_on(async {
let adapter = instance
.request_adapter(&wgpu::RequestAdapterOptions {
power_preference: wgpu::PowerPreference::HighPerformance,
Expand Down Expand Up @@ -145,7 +145,7 @@ fn main() -> Result<(), Box<dyn Error>> {
glyph_brush
.draw_queued(
&device,
&mut queue,
&queue,
&mut encoder,
view,
size.width,
Expand Down
14 changes: 7 additions & 7 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ where
fn process_queued(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
region: Option<Region>,
) {
let pipeline = &mut self.pipeline;
Expand Down Expand Up @@ -238,7 +238,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<(), F, H> {
pub fn draw_queued(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
target_width: u32,
Expand Down Expand Up @@ -268,7 +268,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<(), F, H> {
pub fn draw_queued_with_transform(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
transform: [f32; 16],
Expand All @@ -294,7 +294,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<(), F, H> {
pub fn draw_queued_with_transform_and_scissoring(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
transform: [f32; 16],
Expand Down Expand Up @@ -344,7 +344,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<wgpu::DepthStencilState, F, H> {
pub fn draw_queued(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
depth_stencil_attachment: wgpu::RenderPassDepthStencilAttachment,
Expand Down Expand Up @@ -376,7 +376,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<wgpu::DepthStencilState, F, H> {
pub fn draw_queued_with_transform(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
depth_stencil_attachment: wgpu::RenderPassDepthStencilAttachment,
Expand Down Expand Up @@ -409,7 +409,7 @@ impl<F: Font + Sync, H: BuildHasher> GlyphBrush<wgpu::DepthStencilState, F, H> {
pub fn draw_queued_with_transform_and_scissoring(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
depth_stencil_attachment: wgpu::RenderPassDepthStencilAttachment,
Expand Down
14 changes: 8 additions & 6 deletions src/pipeline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ impl Pipeline<()> {

pub fn draw(
&mut self,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
transform: [f32; 16],
Expand Down Expand Up @@ -72,7 +72,7 @@ impl Pipeline<wgpu::DepthStencilState> {

pub fn draw(
&mut self,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
depth_stencil_attachment: wgpu::RenderPassDepthStencilAttachment,
Expand All @@ -92,7 +92,7 @@ impl Pipeline<wgpu::DepthStencilState> {
impl<Depth> Pipeline<Depth> {
pub fn update_cache(
&mut self,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
offset: [u16; 2],
size: [u16; 2],
data: &[u8],
Expand Down Expand Up @@ -120,7 +120,7 @@ impl<Depth> Pipeline<Depth> {
pub fn upload(
&mut self,
device: &wgpu::Device,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
instances: &mut [Instance],
region: Option<Region>,
) {
Expand Down Expand Up @@ -215,7 +215,9 @@ fn build<D>(
wgpu::BindGroupLayoutEntry {
binding: 1,
visibility: wgpu::ShaderStages::FRAGMENT,
ty: wgpu::BindingType::Sampler(wgpu::SamplerBindingType::Filtering),
ty: wgpu::BindingType::Sampler(
wgpu::SamplerBindingType::Filtering,
),
count: None,
},
wgpu::BindGroupLayoutEntry {
Expand Down Expand Up @@ -330,7 +332,7 @@ fn build<D>(

fn draw<D>(
pipeline: &mut Pipeline<D>,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
encoder: &mut wgpu::CommandEncoder,
target: &wgpu::TextureView,
depth_stencil_attachment: Option<wgpu::RenderPassDepthStencilAttachment>,
Expand Down
2 changes: 1 addition & 1 deletion src/pipeline/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ impl Cache {

pub fn update(
&mut self,
queue: &mut wgpu::Queue,
queue: &wgpu::Queue,
offset: [u16; 2],
size: [u16; 2],
data: &[u8],
Expand Down

0 comments on commit 0506b88

Please sign in to comment.