From b35319131f2f1e4ab2799792d5c2fbf04af2cb6b Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 26 Aug 2021 10:43:39 +0300 Subject: [PATCH 1/4] Discard writes to outside of texture bounds According to GLSL spec calling imageStore with coordinates outside of texture bounds has no effect, but on Intel GPUs it actually results in writes inside the texture, causing an incorrect result. Now the writes are bounds-checked. --- CHANGELOG.md | 7 +++++++ src/haloray-core/resources/shaders/raytrace.glsl | 3 +++ 2 files changed, 10 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ea3e031..3f5f730 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## Unreleased + +### Fixed + +- Writes to the outside of the result texture end up back inside the texture + on some Intel GPUs on Linux. Now they are correctly discarded again. + ## 4.0.0 - 2021-08-25 ### Added diff --git a/src/haloray-core/resources/shaders/raytrace.glsl b/src/haloray-core/resources/shaders/raytrace.glsl index 9a5fa17..341800d 100644 --- a/src/haloray-core/resources/shaders/raytrace.glsl +++ b/src/haloray-core/resources/shaders/raytrace.glsl @@ -771,6 +771,9 @@ void main(void) vec2 projected = camera.focalLength * projectionFunction * vec2(aspectRatio * cos(polarAngle), sin(polarAngle)); vec2 normalizedCoordinates = 0.5 + projected; + if (any(lessThanEqual(normalizedCoordinates, vec2(0.0))) || any(greaterThanEqual(normalizedCoordinates, vec2(1.0)))) + return; + float sunRadiance; if (atmosphereEnabled == 1) { From b159044ab6b28c6263a0b99ad848d812f17e198f Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 26 Aug 2021 10:50:45 +0300 Subject: [PATCH 2/4] Fix guide marking shader to compile on Intel GPU and Linux Intel GPU on Linux refuses to compile the guide marking shader because some constants were initialized with a non-constant expression which depends on a shader uniform. --- CHANGELOG.md | 5 +++-- src/haloray-core/resources/shaders/guide.glsl | 8 ++++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3f5f730..d4c7e79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,8 +10,9 @@ and this project adheres to ### Fixed -- Writes to the outside of the result texture end up back inside the texture - on some Intel GPUs on Linux. Now they are correctly discarded again. +- Fixed bug where writes outside texture bounds ended up inside the texture + on some Intel GPUs on Linux +- Fixed guide marking shader to compile on Linux and Intel GPUs ## 4.0.0 - 2021-08-25 diff --git a/src/haloray-core/resources/shaders/guide.glsl b/src/haloray-core/resources/shaders/guide.glsl index 3577072..e4c36bb 100644 --- a/src/haloray-core/resources/shaders/guide.glsl +++ b/src/haloray-core/resources/shaders/guide.glsl @@ -25,8 +25,12 @@ uniform struct camera_t #define PROJECTION_ORTHOGRAPHIC 4 const float PI = 3.1415926535; -const float LINEWIDTHDEGREES = 0.25 / sqrt(camera.focalLength); -const float LINEWIDTH = LINEWIDTHDEGREES * PI / 180.0; +// The following constants cannot be set to +// `const` because the value depends on a +// shader uniform, and consts must be +// initialized with a constant expression. +float LINEWIDTHDEGREES = 0.25 / sqrt(camera.focalLength); +float LINEWIDTH = LINEWIDTHDEGREES * PI / 180.0; vec2 planarToPolar(vec2 point) { From 7ad091f8e1aa7172d5c90452980f8523f06fd971 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 26 Aug 2021 11:30:03 +0300 Subject: [PATCH 3/4] Update build instructions for Linux --- README.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index b4f690d..56810eb 100644 --- a/README.md +++ b/README.md @@ -180,9 +180,8 @@ Finally build the project by running: ```bash mkdir build -cd src -qmake main.pro -o ..\build\ -cd ..\build +cd build +qmake ../src/haloray.pro make ``` From c79bed310bbf03d9998541c5d6693a132d4e5079 Mon Sep 17 00:00:00 2001 From: Samuli Vuorinen Date: Thu, 26 Aug 2021 13:34:00 +0300 Subject: [PATCH 4/4] Bump version number --- CHANGELOG.md | 2 +- appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4c7e79..9548c89 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -6,7 +6,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). -## Unreleased +## 4.0.1 - 2021-08-26 ### Fixed diff --git a/appveyor.yml b/appveyor.yml index 5711e17..76cf0fc 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: "4.0.0-{build}" +version: "4.0.1-{build}" branches: only: - master