Skip to content

Commit

Permalink
[GL] Remove imports the macros from log crate
Browse files Browse the repository at this point in the history
  • Loading branch information
Gordon-F committed Mar 24, 2021
1 parent 1cbbf11 commit 40f8cf5
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 74 deletions.
34 changes: 17 additions & 17 deletions src/backend/gl/src/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -493,7 +493,7 @@ impl CommandBuffer {
let binding = attribute.binding as usize;

if vertex_buffers.len() <= binding {
error!("No vertex buffer bound at {}", binding);
log::error!("No vertex buffer bound at {}", binding);
}

let (handle, range) = vertex_buffers[binding].as_ref().unwrap();
Expand All @@ -514,7 +514,7 @@ impl CommandBuffer {
desc.rate.as_uint() as u32,
));
}
_ => error!("No vertex buffer description bound at {}", binding),
_ => log::error!("No vertex buffer description bound at {}", binding),
}
}
}
Expand Down Expand Up @@ -665,7 +665,7 @@ impl CommandBuffer {
J: Iterator<Item = command::DescriptorSetOffset>,
{
if let Some(_) = offsets.next() {
warn!("Dynamic offsets are not supported yet");
log::warn!("Dynamic offsets are not supported yet");
}

let mut dirty_textures = 0u32;
Expand Down Expand Up @@ -743,7 +743,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {

unsafe fn reset(&mut self, _release_resources: bool) {
if !self.individual_reset {
error!("Associated pool must allow individual resets.");
log::error!("Associated pool must allow individual resets.");
return;
}

Expand Down Expand Up @@ -995,7 +995,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
) where
T: Iterator<Item = command::ImageBlit>,
{
error!("Blit is not implemented");
log::error!("Blit is not implemented");
}

unsafe fn bind_index_buffer(
Expand Down Expand Up @@ -1058,7 +1058,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {

match len {
0 => {
error!("Number of viewports can not be zero.");
log::error!("Number of viewports can not be zero.");
self.cache.error_state = true;
}
n if n + first_viewport as usize <= self.limits.max_viewports => {
Expand All @@ -1069,7 +1069,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
});
}
_ => {
error!("Number of viewports and first viewport index exceed the number of maximum viewports");
log::error!("Number of viewports and first viewport index exceed the number of maximum viewports");
self.cache.error_state = true;
}
}
Expand All @@ -1094,15 +1094,15 @@ impl command::CommandBuffer<Backend> for CommandBuffer {

match len {
0 => {
error!("Number of scissors can not be zero.");
log::error!("Number of scissors can not be zero.");
self.cache.error_state = true;
}
n if n + first_scissor as usize <= self.limits.max_viewports => {
self.data
.push_cmd(Command::SetScissors(first_scissor, scissors_ptr));
}
_ => {
error!("Number of scissors and first scissor index exceed the maximum number of viewports");
log::error!("Number of scissors and first scissor index exceed the maximum number of viewports");
self.cache.error_state = true;
}
}
Expand Down Expand Up @@ -1150,7 +1150,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
}

unsafe fn set_depth_bounds(&mut self, _: Range<f32>) {
warn!("Depth bounds test is not supported");
log::warn!("Depth bounds test is not supported");
}

unsafe fn set_line_width(&mut self, _width: f32) {
Expand Down Expand Up @@ -1293,7 +1293,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
}

if self.data.buf.size == old_size {
error!("At least one region must be specified");
log::error!("At least one region must be specified");
}
}

Expand Down Expand Up @@ -1325,7 +1325,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
}

if self.data.buf.size == old_size {
error!("At least one region must be specified");
log::error!("At least one region must be specified");
}
}

Expand Down Expand Up @@ -1366,7 +1366,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
}

if self.data.buf.size == old_size {
error!("At least one region must be specified");
log::error!("At least one region must be specified");
}
}

Expand Down Expand Up @@ -1407,7 +1407,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
}

if self.data.buf.size == old_size {
error!("At least one region must be specified");
log::error!("At least one region must be specified");
}
}

Expand Down Expand Up @@ -1436,7 +1436,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
});
}
None => {
warn!("No primitive bound. An active pipeline needs to be bound before calling `draw`.");
log::warn!("No primitive bound. An active pipeline needs to be bound before calling `draw`.");
self.cache.error_state = true;
}
}
Expand All @@ -1462,7 +1462,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
let (index_type, buffer_range) = match &self.cache.index_type_range {
Some((index_type, buffer_range)) => (index_type, buffer_range),
None => {
warn!("No index type bound. An index buffer needs to be bound before calling `draw_indexed`.");
log::warn!("No index type bound. An index buffer needs to be bound before calling `draw_indexed`.");
self.cache.error_state = true;
return;
}
Expand Down Expand Up @@ -1491,7 +1491,7 @@ impl command::CommandBuffer<Backend> for CommandBuffer {
});
}
None => {
warn!("No primitive bound. An active pipeline needs to be bound before calling `draw_indexed`.");
log::warn!("No primitive bound. An active pipeline needs to be bound before calling `draw_indexed`.");
self.cache.error_state = true;
}
}
Expand Down
42 changes: 21 additions & 21 deletions src/backend/gl/src/device.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ fn create_fbo_internal(
if share.private_caps.framebuffer {
let gl = &share.context;
let name = unsafe { gl.create_framebuffer() }.unwrap();
info!("\tCreated frame buffer {:?}", name);
log::info!("\tCreated frame buffer {:?}", name);
Some(name)
} else {
None
Expand Down Expand Up @@ -122,7 +122,7 @@ impl Device {
gl.shader_source(name, shader);
gl.compile_shader(name);
}
info!("\tCompiled shader {:?}", name);
log::info!("\tCompiled shader {:?}", name);
if cfg!(debug_assertions) {
let err = super::Error::from_error_code(unsafe { gl.get_error() });
assert_eq!(err, super::Error::NoError, "Error compiling shader");
Expand All @@ -132,7 +132,7 @@ impl Device {
let log = unsafe { gl.get_shader_info_log(name) };
if compiled_ok {
if !log.is_empty() {
warn!("\tLog: {}", log);
log::warn!("\tLog: {}", log);
}
Ok(name)
} else {
Expand Down Expand Up @@ -170,7 +170,7 @@ impl Device {
let shader = self
.compile_shader(point, stage, context.reborrow())
.map_err(|err| {
error!("Compilation failed: {:?}", err);
log::error!("Compilation failed: {:?}", err);
pso::CreationError::Other
})?;
unsafe {
Expand All @@ -190,7 +190,7 @@ impl Device {
version = version,
shader_type = shader_type
);
debug!(
log::debug!(
"Only vertex shader is present. Creating empty fragment shader:\n{}",
shader_src
);
Expand All @@ -209,19 +209,19 @@ impl Device {
unsafe {
gl.link_program(program);
}
info!("\tLinked program {:?}", program);
log::info!("\tLinked program {:?}", program);
if let Err(err) = self.share.check() {
panic!("Error linking program: {:?}", err);
}

let linked_ok = unsafe { gl.get_program_link_status(program) };
let log = unsafe { gl.get_program_info_log(program) };
if !linked_ok {
error!("\tLog: {}", log);
log::error!("\tLog: {}", log);
return Err(pso::CreationError::Other);
}
if !log.is_empty() {
warn!("\tLog: {}", log);
log::warn!("\tLog: {}", log);
}

if !self
Expand Down Expand Up @@ -394,7 +394,7 @@ impl Device {
entry_point.to_string(),
conv::map_naga_stage_to_cross(stage),
));
debug!("SPIR-V options {:?}", compile_options);
log::debug!("SPIR-V options {:?}", compile_options);

ast.set_compiler_options(&compile_options).map_err(|err| {
d::ShaderError::CompilationFailed(match err {
Expand Down Expand Up @@ -604,7 +604,7 @@ impl Device {
let mut writer =
naga::back::glsl::Writer::new(&mut output, &shader.module, &shader.analysis, options)
.map_err(|e| {
warn!("Naga GLSL init: {}", e);
log::warn!("Naga GLSL init: {}", e);
d::ShaderError::CompilationFailed(format!("{:?}", e))
})?;

Expand All @@ -625,11 +625,11 @@ impl Device {
context,
);
let source = String::from_utf8(output).unwrap();
debug!("Naga generated shader:\n{}", source);
log::debug!("Naga generated shader:\n{}", source);
Self::create_shader_module_raw(gl, &source, options.shader_stage)
}
Err(e) => {
warn!("Naga GLSL write: {}", e);
log::warn!("Naga GLSL write: {}", e);
Err(d::ShaderError::CompilationFailed(format!("{:?}", e)))
}
}
Expand Down Expand Up @@ -678,7 +678,7 @@ impl Device {
let glsl = self
.translate_spirv_cross(&mut ast, stage, ep.entry)
.unwrap();
debug!("SPIRV-Cross generated shader:\n{}", glsl);
log::debug!("SPIRV-Cross generated shader:\n{}", glsl);
result = Self::create_shader_module_raw(&self.share.context, &glsl, stage);
}
if result.is_err() && !ep.module.prefer_naga {
Expand Down Expand Up @@ -1123,7 +1123,7 @@ impl d::Device<B> for Device {
.map(|at| at.borrow().clone())
.collect();
debug!("create_framebuffer {:?}", attachments);
log::debug!("create_framebuffer {:?}", attachments);
let target = glow::DRAW_FRAMEBUFFER;
Expand Down Expand Up @@ -1203,17 +1203,17 @@ impl d::Device<B> for Device {
naga::front::spv::Parser::new(raw_data.iter().cloned(), &Default::default());
match parser.parse() {
Ok(module) => {
debug!("Naga module {:#?}", module);
log::debug!("Naga module {:#?}", module);
match naga::proc::Validator::new().validate(&module) {
Ok(analysis) => Some(d::NagaShader { module, analysis }),
Err(e) => {
warn!("Naga validation failed: {:?}", e);
log::warn!("Naga validation failed: {:?}", e);
None
}
}
}
Err(e) => {
warn!("Naga parsing failed: {:?}", e);
log::warn!("Naga parsing failed: {:?}", e);
None
}
}
Expand Down Expand Up @@ -1695,14 +1695,14 @@ impl d::Device<B> for Device {
Some(description) => {
let raw_view_format = description.tex_internal;
if format != raw_view_format {
warn!(
log::warn!(
"View format {:?} is different from base {:?}",
raw_view_format, format
);
}
}
None => {
warn!("View format {:?} is not supported", view_format);
log::warn!("View format {:?} is not supported", view_format);
}
}
Ok(n::ImageView::Texture {
Expand Down Expand Up @@ -1869,7 +1869,7 @@ impl d::Device<B> for Device {
match *fence {
n::Fence::Idle { signaled } => {
if !signaled {
warn!("Fence ptr {:?} is not pending, waiting not possible", fence);
log::warn!("Fence ptr {:?} is not pending, waiting not possible", fence);
}
Ok(signaled)
}
Expand All @@ -1879,7 +1879,7 @@ impl d::Device<B> for Device {
glow::TIMEOUT_EXPIRED => Ok(false),
glow::WAIT_FAILED => {
if let Err(err) = self.share.check() {
error!("Error when waiting on fence: {:?}", err);
log::error!("Error when waiting on fence: {:?}", err);
}
Ok(false)
}
Expand Down
29 changes: 13 additions & 16 deletions src/backend/gl/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@ will be minimal, if any.

#![allow(missing_docs, missing_copy_implementations)]

#[macro_use]
extern crate log;

use std::{
cell::Cell,
collections::HashMap,
Expand Down Expand Up @@ -179,7 +176,7 @@ fn debug_message_callback(source: u32, gltype: u32, id: u32, severity: u32, mess
_ => unreachable!(),
};

log!(
log::log!(
log_severity,
"[{}/{}] ID {} : {}",
source_str,
Expand Down Expand Up @@ -239,7 +236,7 @@ impl Share {
}
}
if type_mask == 0 {
error!(
log::error!(
"gl backend capability does not allow a buffer with usage {:?}",
usage
);
Expand Down Expand Up @@ -358,17 +355,17 @@ impl PhysicalDevice {
// query information
let (info, supported_features, legacy_features, public_caps, private_caps) =
info::query_all(&gl);
info!("Vendor: {:?}", info.platform_name.vendor);
info!("Renderer: {:?}", info.platform_name.renderer);
info!("Version: {:?}", info.version);
info!("Shading Language: {:?}", info.shading_language);
info!("Supported Features: {:?}", supported_features);
info!("Legacy Features: {:?}", legacy_features);
debug!("Public capabilities: {:#?}", public_caps);
debug!("Private capabilities: {:#?}", private_caps);
debug!("Loaded Extensions:");
log::info!("Vendor: {:?}", info.platform_name.vendor);
log::info!("Renderer: {:?}", info.platform_name.renderer);
log::info!("Version: {:?}", info.version);
log::info!("Shading Language: {:?}", info.shading_language);
log::info!("Supported Features: {:?}", supported_features);
log::info!("Legacy Features: {:?}", legacy_features);
log::debug!("Public capabilities: {:#?}", public_caps);
log::debug!("Private capabilities: {:#?}", private_caps);
log::debug!("Loaded Extensions:");
for extension in info.extensions.iter() {
debug!("- {}", *extension);
log::debug!("- {}", *extension);
}
let name = info.platform_name.renderer.clone();
let vendor: std::string::String = info.platform_name.vendor.clone();
Expand Down Expand Up @@ -547,7 +544,7 @@ impl adapter::PhysicalDevice<Backend> for PhysicalDevice {
let gl = &self.0.context;

if cfg!(debug_assertions) && !cfg!(target_arch = "wasm32") && gl.supports_debug() {
info!("Debug output is enabled");
log::info!("Debug output is enabled");
gl.enable(glow::DEBUG_OUTPUT);
gl.debug_message_callback(debug_message_callback);
}
Expand Down
Loading

0 comments on commit 40f8cf5

Please sign in to comment.