From 30daf10cdd6ea4d3d0f52f0cf43e2c0c29b134de Mon Sep 17 00:00:00 2001 From: Patrick Walton Date: Wed, 25 Jan 2017 20:25:54 -0800 Subject: [PATCH] Fix syntax on Linux; drop GL version to 3.3 --- examples/generate-atlas.rs | 2 +- resources/shaders/accum.cs.glsl | 10 +++++++--- resources/shaders/draw.fs.glsl | 2 +- resources/shaders/draw.gs.glsl | 14 +++++++------- resources/shaders/draw.tcs.glsl | 2 +- resources/shaders/draw.vs.glsl | 4 ++-- 6 files changed, 19 insertions(+), 15 deletions(-) diff --git a/examples/generate-atlas.rs b/examples/generate-atlas.rs index 292ca5aa..97a62d52 100644 --- a/examples/generate-atlas.rs +++ b/examples/generate-atlas.rs @@ -32,7 +32,7 @@ const SHELF_HEIGHT: u32 = 32; fn main() { let mut glfw = glfw::init(glfw::LOG_ERRORS).unwrap(); - glfw.window_hint(WindowHint::ContextVersion(4, 1)); + glfw.window_hint(WindowHint::ContextVersion(3, 3)); glfw.window_hint(WindowHint::OpenGlForwardCompat(true)); glfw.window_hint(WindowHint::OpenGlProfile(OpenGlProfileHint::Core)); let context = glfw.create_window(WIDTH, HEIGHT, "generate-atlas", WindowMode::Windowed); diff --git a/resources/shaders/accum.cs.glsl b/resources/shaders/accum.cs.glsl index 5cb8cc7e..149055b3 100644 --- a/resources/shaders/accum.cs.glsl +++ b/resources/shaders/accum.cs.glsl @@ -17,9 +17,12 @@ #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 -uniform uimage2DRect uTexture; +layout(local_size_x = 1024) in; + +uniform restrict writeonly uimage2DRect uTexture; uniform sampler2DRect uCoverage; uniform uvec4 uAtlasRect; uniform uint uAtlasShelfHeight; @@ -29,13 +32,14 @@ void main() { uint atlasWidth = uAtlasRect.z - uAtlasRect.x; uint column = gl_GlobalInvocationID.x % atlasWidth; uint shelfIndex = gl_GlobalInvocationID.x / atlasWidth; - uint firstRow = shelfIndex * uAtlasShelfHeight, lastRow = (shelfIndex + 1) * uAtlasShelfHeight; + uint firstRow = shelfIndex * uAtlasShelfHeight; + uint lastRow = (shelfIndex + 1u) * uAtlasShelfHeight; // Sweep down the column, accumulating coverage as we go. float coverage = 0.0f; for (uint row = firstRow; row < lastRow; row++) { ivec2 coord = ivec2(column, row); - coverage += texelFetch(uCoverage, coord); + coverage += texelFetch(uCoverage, coord).r; uint gray = uint(clamp(coverage, 0.0f, 1.0f) * 255.0f); imageStore(uTexture, coord + ivec2(uAtlasRect.xy), uvec4(gray, 255, 255, 255)); diff --git a/resources/shaders/draw.fs.glsl b/resources/shaders/draw.fs.glsl index 7e348c06..45e2bb54 100644 --- a/resources/shaders/draw.fs.glsl +++ b/resources/shaders/draw.fs.glsl @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#version 410 +#version 330 // The size of the atlas in pixels. uniform uvec2 uAtlasSize; diff --git a/resources/shaders/draw.gs.glsl b/resources/shaders/draw.gs.glsl index b2336261..fa796b7b 100644 --- a/resources/shaders/draw.gs.glsl +++ b/resources/shaders/draw.gs.glsl @@ -17,7 +17,7 @@ // To use this shader, set `RasterizerOptions::force_geometry_shader` to true or set the // environment variable `PATHFINDER_FORCE_GEOMETRY_SHADER` to 1. -#version 410 +#version 330 #define CURVE_THRESHOLD 0.333f #define CURVE_TOLERANCE 3.0f @@ -39,7 +39,7 @@ layout(triangle_strip, max_vertices = 256) out; uniform uvec2 uAtlasSize; // The vertex ID, passed into this shader. -flat in uint vVertexID[]; +flat in int vVertexID[]; // The starting point of the segment. flat out vec2 vP0; @@ -69,7 +69,7 @@ void main() { } // Determine how many lines to divide into. - uint lineCount = 1; + uint lineCount = 1u; if (vVertexID[1] > 0) { // Quadratic curve. vec2 dev = p0 - 2.0f * p1 + p2; @@ -82,16 +82,16 @@ void main() { } // Divide into lines. - for (uint lineIndex = 0; lineIndex < lineCount; lineIndex++) { + for (uint lineIndex = 0u; lineIndex < lineCount; lineIndex++) { // Compute our endpoints (trivial if this is part of a line, less trivial if this is part // of a curve). vec2 lP0, lP1; - if (lineCount == 1) { + if (lineCount == 1u) { lP0 = p0; lP1 = p2; } else { - float t0 = float(lineIndex + 0) / float(lineCount); - float t1 = float(lineIndex + 1) / float(lineCount); + float t0 = float(lineIndex + 0u) / float(lineCount); + float t1 = float(lineIndex + 1u) / float(lineCount); lP0 = mix(mix(p0, p1, t0), mix(p1, p2, t0), t0); lP1 = mix(mix(p0, p1, t1), mix(p1, p2, t1), t1); } diff --git a/resources/shaders/draw.tcs.glsl b/resources/shaders/draw.tcs.glsl index c967caa8..0c689083 100644 --- a/resources/shaders/draw.tcs.glsl +++ b/resources/shaders/draw.tcs.glsl @@ -16,7 +16,7 @@ layout(vertices = 1) out; // The vertex ID, passed into this shader. -flat in uint vVertexID[]; +flat in int vVertexID[]; // The starting point of the segment. patch out vec2 vpP0; diff --git a/resources/shaders/draw.vs.glsl b/resources/shaders/draw.vs.glsl index 308bd76b..a5ebb683 100644 --- a/resources/shaders/draw.vs.glsl +++ b/resources/shaders/draw.vs.glsl @@ -8,7 +8,7 @@ // option. This file may not be copied, modified, or distributed // except according to those terms. -#version 410 +#version 330 #define MAX_GLYPHS 2048 @@ -45,7 +45,7 @@ in ivec2 aPosition; in uint aGlyphIndex; // The vertex ID, passed along onto the TCS. -flat out uint vVertexID; +flat out int vVertexID; void main() { vVertexID = gl_VertexID;