Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wgpu: Cache Program3D bind group layout #11526

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 5 additions & 15 deletions core/src/avm2/object/context3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,9 +249,8 @@ impl<'gc> Context3DObject<'gc> {
.unwrap()
.process_command(
Context3DCommand::UploadShaders {
vertex_shader: program.vertex_shader_handle(),
module: program.shader_module_handle(),
vertex_shader_agal,
fragment_shader: program.fragment_shader_handle(),
fragment_shader_agal,
},
activation.context.gc_context,
Expand All @@ -263,15 +262,9 @@ impl<'gc> Context3DObject<'gc> {
activation: &mut Activation<'_, 'gc>,
program: Option<Program3DObject<'gc>>,
) {
let (vertex_shader, fragment_shader) = match program {
Some(program) => (
program.vertex_shader_handle(),
program.fragment_shader_handle(),
),
None => (
GcCell::allocate(activation.context.gc_context, None),
GcCell::allocate(activation.context.gc_context, None),
),
let module = match program {
Some(program) => program.shader_module_handle(),
None => GcCell::allocate(activation.context.gc_context, None),
};

self.0
Expand All @@ -280,10 +273,7 @@ impl<'gc> Context3DObject<'gc> {
.as_mut()
.unwrap()
.process_command(
Context3DCommand::SetShaders {
vertex_shader,
fragment_shader,
},
Context3DCommand::SetShaders { module },
activation.context.gc_context,
);
}
Expand Down
15 changes: 4 additions & 11 deletions core/src/avm2/object/program_3d_object.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ impl<'gc> Program3DObject<'gc> {
Program3DObjectData {
base,
context3d,
vertex_shader_handle: GcCell::allocate(activation.context.gc_context, None),
fragment_shader_handle: GcCell::allocate(activation.context.gc_context, None),
shader_module_handle: GcCell::allocate(activation.context.gc_context, None),
},
))
.into();
Expand All @@ -45,12 +44,8 @@ impl<'gc> Program3DObject<'gc> {
Ok(this)
}

pub fn vertex_shader_handle(&self) -> GcCell<'gc, Option<Rc<dyn ShaderModule>>> {
self.0.read().vertex_shader_handle
}

pub fn fragment_shader_handle(&self) -> GcCell<'gc, Option<Rc<dyn ShaderModule>>> {
self.0.read().fragment_shader_handle
pub fn shader_module_handle(&self) -> GcCell<'gc, Option<Rc<dyn ShaderModule>>> {
self.0.read().shader_module_handle
}

pub fn context3d(&self) -> Context3DObject<'gc> {
Expand All @@ -66,9 +61,7 @@ pub struct Program3DObjectData<'gc> {

context3d: Context3DObject<'gc>,

vertex_shader_handle: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,

fragment_shader_handle: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
shader_module_handle: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
}

impl<'gc> TObject<'gc> for Program3DObject<'gc> {
Expand Down
6 changes: 2 additions & 4 deletions render/src/backend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -429,15 +429,13 @@ pub enum Context3DCommand<'a, 'gc> {
},

UploadShaders {
vertex_shader: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
module: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
vertex_shader_agal: Vec<u8>,
fragment_shader: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
fragment_shader_agal: Vec<u8>,
},

SetShaders {
vertex_shader: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
fragment_shader: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
module: GcCell<'gc, Option<Rc<dyn ShaderModule>>>,
},
SetProgramConstantsFromVector {
program_type: ProgramType,
Expand Down
Loading