티스토리 뷰
먼가 모르는 것도 있고, 테스트
참고자료:
http://timjones.io/blog/archive/2018/05/19/introducing-shader-playground
http://shader-playground.timjones.io/
설명이 hpp 파일에 되어있다; default value 와 함께
[--no-420pack-extension]
420pack-extension은 c++의 aggregate contructor와 비슷한것으로 보인다
https://www.khronos.org/registry/OpenGL/extensions/ARB/ARB_shading_language_420pack.txt
initial value for an aggregate variable 라고 한다.
initializer :
assignment-expression
{ initializer-list }
{ initializer-list , }
"Applying these rules, the following matrix declarations are equivalent:
mat2x2 a = mat2( vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ) );
mat2x2 b = { vec2( 1.0, 0.0 ), vec2( 0.0, 1.0 ) };
mat2x2 c = { { 1.0, 0.0 }, { 0.0, 1.0 } };
이번 소스에는 영향 받는게 없는 듯
--- main.frag.glsl.420 2019-06-25 11:32:41.647368600 +0900
+++ main.frag.glsl 2019-06-25 11:18:51.021067000 +0900
@@ -1,4 +1,7 @@
#version 120
+#ifdef GL_ARB_shading_language_420pack
+#extension GL_ARB_shading_language_420pack : require
+#endif
struct Uniform
{
[--reflect]
UBO 크기 등을 보여주는 json 생성
https://github.com/KhronosGroup/SPIRV-Cross/wiki/Reflection-API-user-guide
"_22" : {
"name" : "Uniforms",
"members" : [
{
"name" : "u_MVPMatrix",
"type" : "mat4",
"offset" : 0
},
{
"name" : "u_fWidth",
"type" : "float",
"offset" : 64
},
{
"name" : "u_fHeight",
"type" : "float",
"offset" : 68
},
...
"ubos" : [
{
"type" : "_22",
"name" : "Uniforms",
"block_size" : 76,
"set" : 0,
"binding" : 0
}
]
[--flatten-ubo]
glUniform4fv로 한번에 업데이트 하자
[--remove-unused-variables]
디폴트 아니였나
[--emit-line-directives]
GLSL include에서 파일 위치 파악하는데 쓰이는 것과 같은 건가
vert / frag 모두 변화 없다.
include가 필요한가? 변화가 없다;
// Emit OpLine directives if present in the module.
// May not correspond exactly to original source, but should be a good approximation.
bool emit_line_directives = false;
[--flip-vert-y]
y invert
[--msl-ios]
Platform platform = macOS
struct 초기화
http://shader-playground.timjones.io/102f87ecbd58a81ba26f4e02e32276c0
GLSL은 안보임; 죄다 최적화 되버리니
로컬에서 하니까;
#version 450
struct Hello
{
vec3 hi;
vec3 hello;
vec4 r;
};
struct PSInput
{
vec4 color;
};
layout(location = 0) in vec4 input_color;
layout(location = 0) out vec4 _entryPointOutput;
void test(inout Hello e)
{
e.hello += vec3(0.0, 1.0, 0.20000000298023223876953125);
e.hi += vec3(1.0, 0.0, 0.100000001490116119384765625);
e.hi *= e.hello;
e.r = vec4(e.hi, 10.0);
}
vec4 _PSMain(PSInput _input)
{
Hello hi = Hello(vec3(0.0), vec3(0.0), vec4(0.0));
Hello param = hi;
test(param);
hi = param;
return hi.r;
}
void main()
{
PSInput _input;
_input.color = input_color;
PSInput param = _input;
_entryPointOutput = _PSMain(param);
}
왜케 차이가 나는가?
./glslangValidator.exe -V -o main.vert.spv main.vert -Os
뒤의 size otimizer 수행 여부이다
이걸 할려면,
If you wish to assure that SPIR-V generated from HLSL is legal for Vulkan,
or wish to invoke -Os to reduce SPIR-V size from HLSL or GLSL, install
spirv-tools with this:
./update_glslang_sources.py
cmake 결과가 달라진다
$ diff -uNr before.txt after.txt
--- before.txt 2019-06-25 13:21:25.297771500 +0900
+++ after.txt 2019-06-25 13:21:23.595822700 +0900
@@ -7,8 +7,9 @@
-- Using RelWithDebInfo VC++ CRT: MD
-- Using Debug VC++ CRT: MDd
-- Google Mock was not found - tests based on that will not build
--- spirv-tools not linked - illegal SPIRV may be generated for HLSL
+-- SPIRV-Tools: nosetests was not found - python support code will not be tested
+-- Found PythonInterp: C:/Python27/python.exe (found version "2.7.14")
+-- optimizer enabled
-- Configuring done
-- Generating done
-- Build files have been written to: C:/Projects/SPIRV-Cross/external/glslang-build
-
SPIR-V Optimizer 옵션 설명
https://vulkan.lunarg.com/doc/view/1.0.61.1/windows/spirv_toolchain.html
- Total
- Today
- Yesterday