Try to fix Linux/Windows

This commit is contained in:
Patrick Walton 2017-02-14 12:29:30 -08:00
parent 731360bc9d
commit 1b10ffdd54
3 changed files with 43 additions and 10 deletions

View File

@ -14,13 +14,6 @@
//
// [1]: https://medium.com/@raphlinus/inside-the-fastest-font-renderer-in-the-world-75ae5270c445
#version 330
#extension GL_ARB_compute_shader : require
#extension GL_ARB_explicit_uniform_location : require
#extension GL_ARB_shader_image_load_store : require
#extension GL_ARB_shader_storage_buffer_object : require
#extension GL_ARB_shading_language_420pack : require
layout(local_size_x = 1024) in;
layout(IMAGE_FORMAT, binding = 0) uniform restrict writeonly image2DRect uImage;

View File

@ -0,0 +1,17 @@
// Copyright 2017 The Servo Project Developers. See the COPYRIGHT
// file at the top-level directory of this distribution and at
// http://rust-lang.org/COPYRIGHT.
//
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
// option. This file may not be copied, modified, or distributed
// except according to those terms.
#version 330
#extension GL_ARB_compute_shader : require
#extension GL_ARB_explicit_uniform_location : require
#extension GL_ARB_shader_image_load_store : require
#extension GL_ARB_shader_storage_buffer_object : require
#extension GL_ARB_shading_language_420pack : require

View File

@ -31,6 +31,8 @@ use std::mem;
use std::path::{Path, PathBuf};
use std::ptr;
static COMPUTE_PREAMBLE_FILENAME: &'static str = "preamble.cs.glsl";
static ACCUM_CL_SHADER_FILENAME: &'static str = "accum.cl";
static ACCUM_COMPUTE_SHADER_FILENAME: &'static str = "accum.cs.glsl";
@ -158,19 +160,40 @@ impl Rasterizer {
let mut accum_path = options.shader_path.to_owned();
accum_path.push(accum_filename);
let mut accum_file = match File::open(&accum_path) {
Err(error) => return Err(InitError::ShaderUnreadable(error)),
Ok(file) => file,
};
let mut compute_preamble_source = String::new();
match shading_language {
ShadingLanguage::Cl => {}
ShadingLanguage::Glsl => {
let mut compute_preamble_path = options.shader_path.to_owned();
compute_preamble_path.push(COMPUTE_PREAMBLE_FILENAME);
let mut compute_preamble_file = match File::open(&compute_preamble_path) {
Err(error) => return Err(InitError::ShaderUnreadable(error)),
Ok(file) => file,
};
if compute_preamble_file.read_to_string(&mut compute_preamble_source).is_err() {
return Err(InitError::CompileFailed("Compute shader",
"Invalid UTF-8".to_string()))
}
}
}
let mut accum_source = String::new();
if accum_file.read_to_string(&mut accum_source).is_err() {
return Err(InitError::CompileFailed("Compute shader", "Invalid UTF-8".to_string()))
}
let accum_source_r8 = format!("#define IMAGE_FORMAT r8\n{}", accum_source);
let accum_source_rgba8 = format!("#define IMAGE_FORMAT rgba8\n{}", accum_source);
let accum_source_r8 = format!("{}\n#define IMAGE_FORMAT r8\n{}",
compute_preamble_source,
accum_source);
let accum_source_rgba8 = format!("{}\n#define IMAGE_FORMAT rgba8\n{}",
compute_preamble_source,
accum_source);
let accum_program_r8 = try!(device.create_program(&accum_source_r8)
.map_err(InitError::ComputeError));