cbaggers / varjo

Lisp to GLSL Language Translator
BSD 2-Clause "Simplified" License
223 stars 23 forks source link

Strange autoconversion of integers to floats #234

Open metayan opened 5 years ago

metayan commented 5 years ago

Something seems to have been changed recently, because

(defun-g cube-frag ((tc :vec3) &uniform (tex :sampler-cube))
  (texture tex (* (v! -1 1 1) tc)))

suddenly gives:

Error compiling fragment-shader: 
ERROR: 0:15: 'f' : syntax error: syntax error

// fragment-stage
#version 410

in _FROM_VERTEX_STAGE_
{
     in vec3 _VERTEX_STAGE_OUT_1;
} v_in;

layout(location = 0)  out vec4 _FRAGMENT_STAGE_OUT_0;

uniform samplerCube TEX;

void main()
{
    _FRAGMENT_STAGE_OUT_0 = texture(TEX,(vec3(-1f,1f,1f) * v_in._VERTEX_STAGE_OUT_1));
    return;
}
metayan commented 5 years ago

Until https://github.com/cbaggers/varjo/commit/24da4aebe1c9ecaeb3d6dee2b3051a3b31836841 this was emitted:

void main()
{
    _FRAGMENT_STAGE_OUT_0 = texture(TEX,(vec3(float(-1),float(1),float(1)) * v_in._VERTEX_STAGE_OUT_1));
    return;
}
metayan commented 5 years ago

By the way, how cool is it that we can checkout a different version of a package and just ql:quickload it into a running program? Discovering more and more Lisp awesomeness. ;) (And most likely there is a SLIME shortcut – or some day will be – to do this automagically. load-previous/next-version-of-package :) )

cbaggers commented 5 years ago

@metayan yeah it's rad!

The change was that, in cases where we used to use scalar constructors on literal integers, we now just emit the correct literal. For example rather than (float 2) we emit 2f.

However, some drivers don't seem to like 2f and instead require 2.0f so I've fixed that. Should be good now on master