mirror of
https://github.com/storytold/wgpu.git
synced 2026-11-22 23:41:01 +01:00
hal/gles: Update glow and fill up the missing methods
This commit is contained in:
1 parent
bf61908824
commit
403ff6faf8
7 files changed
+87
-47
No files matched your search
Generated
+1
-1
@@ -690,7 +690,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "glow"
|
||||
version = "0.10.0"
|
||||
source = "git+https://github.com/grovesNL/glow?rev=23d16276aaa8095d9ae507b1f70d0c9edfe3527f#23d16276aaa8095d9ae507b1f70d0c9edfe3527f"
|
||||
source = "git+https://github.com/kvark/glow?branch=missing-stuff#23a3f95b396ef7b3a99054494f331af25c071705"
|
||||
dependencies = [
|
||||
"js-sys",
|
||||
"slotmap",
|
||||
|
||||
@@ -855,6 +855,7 @@ impl HalApi for hal::api::Dx11 {
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
#[cfg(gl)]
|
||||
impl HalApi for hal::api::Gles {
|
||||
const VARIANT: Backend = Backend::Gl;
|
||||
|
||||
+1
-1
@@ -38,7 +38,7 @@ gpu-descriptor = { version = "0.1", optional = true }
|
||||
inplace_it = { version ="0.3.3", optional = true }
|
||||
renderdoc-sys = { version = "0.7.1", optional = true }
|
||||
# backend: Gles
|
||||
glow = { git = "https://github.com/grovesNL/glow", rev = "23d16276aaa8095d9ae507b1f70d0c9edfe3527f", optional = true }
|
||||
glow = { git = "https://github.com/kvark/glow", branch = "missing-stuff", optional = true }
|
||||
|
||||
[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
|
||||
egl = { package = "khronos-egl", version = "4.1", features = ["dynamic"], optional = true }
|
||||
|
||||
@@ -190,8 +190,6 @@ impl super::Adapter {
|
||||
| wgt::DownlevelFlags::CUBE_ARRAY_TEXTURES
|
||||
| wgt::DownlevelFlags::COMPARISON_SAMPLERS;
|
||||
downlevel_flags.set(wgt::DownlevelFlags::COMPUTE_SHADERS, ver >= (3, 1));
|
||||
//Note: storage textures aren't supported atm, only buffers. See
|
||||
// https://github.com/grovesNL/glow/issues/174
|
||||
downlevel_flags.set(
|
||||
wgt::DownlevelFlags::FRAGMENT_WRITABLE_STORAGE,
|
||||
ver >= (3, 1),
|
||||
@@ -245,6 +243,10 @@ impl super::Adapter {
|
||||
};
|
||||
|
||||
let mut private_caps = super::PrivateCapability::empty();
|
||||
private_caps.set(
|
||||
super::PrivateCapability::SHADER_BINDING_LAYOUT,
|
||||
ver >= (3, 1),
|
||||
);
|
||||
private_caps.set(super::PrivateCapability::MEMORY_BARRIERS, ver >= (3, 1));
|
||||
|
||||
Some(crate::ExposedAdapter {
|
||||
|
||||
+31
-13
@@ -114,6 +114,9 @@ impl super::Device {
|
||||
use naga::back::glsl;
|
||||
let options = glsl::Options {
|
||||
version: self.shared.shading_language_version,
|
||||
binding_map: Default::default(), //TODO
|
||||
};
|
||||
let pipeline_options = glsl::PipelineOptions {
|
||||
shader_stage: naga_stage,
|
||||
entry_point: stage.entry_point.to_string(),
|
||||
};
|
||||
@@ -127,11 +130,17 @@ impl super::Device {
|
||||
.ok_or(crate::PipelineError::EntryPoint(naga_stage))?;
|
||||
|
||||
let mut output = String::new();
|
||||
let mut writer = glsl::Writer::new(&mut output, &shader.module, &shader.info, &options)
|
||||
.map_err(|e| {
|
||||
let msg = format!("{}", e);
|
||||
crate::PipelineError::Linkage(map_naga_stage(naga_stage), msg)
|
||||
})?;
|
||||
let mut writer = glsl::Writer::new(
|
||||
&mut output,
|
||||
&shader.module,
|
||||
&shader.info,
|
||||
&options,
|
||||
&pipeline_options,
|
||||
)
|
||||
.map_err(|e| {
|
||||
let msg = format!("{}", e);
|
||||
crate::PipelineError::Linkage(map_naga_stage(naga_stage), msg)
|
||||
})?;
|
||||
|
||||
let reflection_info = writer.write().map_err(|e| {
|
||||
let msg = format!("{}", e);
|
||||
@@ -206,8 +215,13 @@ impl super::Device {
|
||||
log::warn!("\tLink: {}", msg);
|
||||
}
|
||||
|
||||
//TODO: check for `PrivateCapability::EXPLICIT_LAYOUTS_IN_SHADER`?
|
||||
if !self
|
||||
.shared
|
||||
.private_caps
|
||||
.contains(super::PrivateCapability::SHADER_BINDING_LAYOUT)
|
||||
{
|
||||
// This remapping is only needed if we aren't able to put the binding layout
|
||||
// in the shader. We can't remap storage buffers this way.
|
||||
gl.use_program(Some(program));
|
||||
for (ref name, (register, slot)) in name_binding_map {
|
||||
log::trace!("Get binding {:?} from program {:?}", name, program);
|
||||
@@ -223,7 +237,6 @@ impl super::Device {
|
||||
name,
|
||||
index
|
||||
);
|
||||
//gl.shader_storage_block_binding(program, index, slot as _);
|
||||
return Err(crate::DeviceError::Lost.into());
|
||||
}
|
||||
super::BindingRegister::Textures | super::BindingRegister::Images => {
|
||||
@@ -432,10 +445,15 @@ impl crate::Device<super::Api> for super::Device {
|
||||
if desc.sample_count > 1 {
|
||||
let target = glow::TEXTURE_2D;
|
||||
gl.bind_texture(target, Some(raw));
|
||||
// https://github.com/grovesNL/glow/issues/169
|
||||
//gl.tex_storage_2d_multisample(target, desc.sample_count as i32, format_desc.tex_internal, desc.size.width as i32, desc.size.height as i32, true);
|
||||
log::error!("TODO: support `tex_storage_2d_multisample` (https://github.com/grovesNL/glow/issues/169)");
|
||||
return Err(crate::DeviceError::Lost);
|
||||
gl.tex_storage_2d_multisample(
|
||||
target,
|
||||
desc.sample_count as i32,
|
||||
format_desc.internal,
|
||||
desc.size.width as i32,
|
||||
desc.size.height as i32,
|
||||
true,
|
||||
);
|
||||
target
|
||||
} else if desc.size.depth_or_array_layers > 1 {
|
||||
let target = glow::TEXTURE_2D_ARRAY;
|
||||
gl.bind_texture(target, Some(raw));
|
||||
@@ -579,12 +597,12 @@ impl crate::Device<super::Api> for super::Device {
|
||||
);
|
||||
|
||||
if let Some(border_color) = desc.border_color {
|
||||
let mut border = match border_color {
|
||||
let border = match border_color {
|
||||
wgt::SamplerBorderColor::TransparentBlack => [0.0; 4],
|
||||
wgt::SamplerBorderColor::OpaqueBlack => [0.0, 0.0, 0.0, 1.0],
|
||||
wgt::SamplerBorderColor::OpaqueWhite => [1.0; 4],
|
||||
};
|
||||
gl.sampler_parameter_f32_slice(raw, glow::TEXTURE_BORDER_COLOR, &mut border);
|
||||
gl.sampler_parameter_f32_slice(raw, glow::TEXTURE_BORDER_COLOR, &border);
|
||||
}
|
||||
|
||||
if let Some(ref range) = desc.lod_clamp {
|
||||
|
||||
@@ -53,8 +53,10 @@ bitflags::bitflags! {
|
||||
/// Flags that affect internal code paths but do not
|
||||
/// change the exposed feature set.
|
||||
struct PrivateCapability: u32 {
|
||||
/// Support explicit layouts in shader.
|
||||
const SHADER_BINDING_LAYOUT = 0x0001;
|
||||
/// Support memory barriers.
|
||||
const MEMORY_BARRIERS = 0x0001;
|
||||
const MEMORY_BARRIERS = 0x0002;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+46
-29
@@ -21,7 +21,6 @@ impl super::Queue {
|
||||
let gl = &self.shared.context;
|
||||
gl.use_program(None);
|
||||
gl.bind_framebuffer(glow::FRAMEBUFFER, None);
|
||||
gl.polygon_offset(0.0, 0.0);
|
||||
gl.disable(glow::DEPTH_TEST);
|
||||
gl.disable(glow::STENCIL_TEST);
|
||||
gl.disable(glow::SCISSOR_TEST);
|
||||
@@ -119,22 +118,21 @@ impl super::Queue {
|
||||
),
|
||||
},
|
||||
C::DrawIndirect {
|
||||
topology: _,
|
||||
topology,
|
||||
indirect_buf,
|
||||
indirect_offset: _,
|
||||
indirect_offset,
|
||||
} => {
|
||||
gl.bind_buffer(glow::DRAW_INDIRECT_BUFFER, Some(indirect_buf));
|
||||
//TODO: https://github.com/grovesNL/glow/issues/172
|
||||
//gl.draw_arrays_indirect(topology, indirect_offset);
|
||||
gl.draw_arrays_indirect_offset(topology, indirect_offset as i32);
|
||||
}
|
||||
C::DrawIndexedIndirect {
|
||||
topology: _,
|
||||
index_type: _,
|
||||
topology,
|
||||
index_type,
|
||||
indirect_buf,
|
||||
indirect_offset: _,
|
||||
indirect_offset,
|
||||
} => {
|
||||
gl.bind_buffer(glow::DRAW_INDIRECT_BUFFER, Some(indirect_buf));
|
||||
//TODO: https://github.com/grovesNL/glow/issues/172
|
||||
gl.draw_elements_indirect_offset(topology, index_type, indirect_offset as i32);
|
||||
}
|
||||
C::Dispatch(group_counts) => {
|
||||
gl.dispatch_compute(group_counts[0], group_counts[1], group_counts[2]);
|
||||
@@ -194,12 +192,29 @@ impl super::Queue {
|
||||
);
|
||||
}
|
||||
gl.bind_texture(dst_target, Some(dst));
|
||||
//TODO: https://github.com/grovesNL/glow/issues/173
|
||||
#[allow(clippy::if_same_then_else)]
|
||||
if is_3d_target(dst_target) {
|
||||
//gl.copy_tex_sub_image_3d(dst_target, copy.dst_base.mip_level, copy.dst_base.origin.x, copy.dst_base.origin.y, copy.dst_base.origin.z + layer, copy.src_base.origin.x, copy.src_base.origin.y, copy.size.width, copy.size.height);
|
||||
gl.copy_tex_sub_image_3d(
|
||||
dst_target,
|
||||
copy.dst_base.mip_level as i32,
|
||||
copy.dst_base.origin.x as i32,
|
||||
copy.dst_base.origin.y as i32,
|
||||
copy.dst_base.origin.z as i32 + layer,
|
||||
copy.src_base.origin.x as i32,
|
||||
copy.src_base.origin.y as i32,
|
||||
copy.size.width as i32,
|
||||
copy.size.height as i32,
|
||||
);
|
||||
} else {
|
||||
//gl.copy_tex_sub_image_2d(dst_target, copy.dst_base.mip_level, copy.dst_base.origin.x, copy.dst_base.origin.y, copy.src_base.origin.x, copy.src_base.origin.y, copy.size.width, copy.size.height);
|
||||
gl.copy_tex_sub_image_2d(
|
||||
dst_target,
|
||||
copy.dst_base.mip_level as i32,
|
||||
copy.dst_base.origin.x as i32,
|
||||
copy.dst_base.origin.y as i32,
|
||||
copy.src_base.origin.x as i32,
|
||||
copy.src_base.origin.y as i32,
|
||||
copy.size.width as i32,
|
||||
copy.size.height as i32,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,20 +419,20 @@ impl super::Queue {
|
||||
gl.disable_draw_buffer(glow::BLEND, draw_buffer);
|
||||
}
|
||||
}
|
||||
C::ClearColorF(draw_buffer, mut color) => {
|
||||
gl.clear_buffer_f32_slice(glow::COLOR, draw_buffer, &mut color);
|
||||
C::ClearColorF(draw_buffer, ref color) => {
|
||||
gl.clear_buffer_f32_slice(glow::COLOR, draw_buffer, color);
|
||||
}
|
||||
C::ClearColorU(draw_buffer, mut color) => {
|
||||
gl.clear_buffer_u32_slice(glow::COLOR, draw_buffer, &mut color);
|
||||
C::ClearColorU(draw_buffer, ref color) => {
|
||||
gl.clear_buffer_u32_slice(glow::COLOR, draw_buffer, color);
|
||||
}
|
||||
C::ClearColorI(draw_buffer, mut color) => {
|
||||
gl.clear_buffer_i32_slice(glow::COLOR, draw_buffer, &mut color);
|
||||
C::ClearColorI(draw_buffer, ref color) => {
|
||||
gl.clear_buffer_i32_slice(glow::COLOR, draw_buffer, color);
|
||||
}
|
||||
C::ClearDepth(depth) => {
|
||||
gl.clear_buffer_f32_slice(glow::DEPTH, 0, &mut [depth]);
|
||||
gl.clear_buffer_f32_slice(glow::DEPTH, 0, &[depth]);
|
||||
}
|
||||
C::ClearStencil(value) => {
|
||||
gl.clear_buffer_i32_slice(glow::STENCIL, 0, &mut [value as i32]);
|
||||
gl.clear_buffer_i32_slice(glow::STENCIL, 0, &[value as i32]);
|
||||
}
|
||||
C::BufferBarrier(raw, usage) => {
|
||||
let mut flags = 0;
|
||||
@@ -658,14 +673,16 @@ impl super::Queue {
|
||||
gl.active_texture(glow::TEXTURE0 + slot);
|
||||
gl.bind_texture(target, Some(texture));
|
||||
}
|
||||
C::BindImage {
|
||||
slot: _,
|
||||
binding: _,
|
||||
} => {
|
||||
//TODO: https://github.com/grovesNL/glow/issues/174
|
||||
//gl.bind_image_texture(slot, Some(binding.raw), binding.mip_level as i32,
|
||||
// binding.array_layer.is_none(), binding.array_layer.unwrap_or_default(),
|
||||
// binding.access, binding.format);
|
||||
C::BindImage { slot, ref binding } => {
|
||||
gl.bind_image_texture(
|
||||
slot,
|
||||
binding.raw,
|
||||
binding.mip_level as i32,
|
||||
binding.array_layer.is_none(),
|
||||
binding.array_layer.unwrap_or_default() as i32,
|
||||
binding.access,
|
||||
binding.format,
|
||||
);
|
||||
}
|
||||
C::InsertDebugMarker(ref range) => {
|
||||
let marker = extract_marker(data_bytes, range);
|
||||
|
||||
Reference in new issue
Block a user