This commit is contained in:
Branimir Karadžić 2017-05-16 17:29:59 -07:00
parent aed70348c4
commit e8c630c001
3 changed files with 70 additions and 80 deletions

View File

@ -116,19 +116,9 @@ CS_BIN = $(addprefix $(BUILD_INTERMEDIATE_DIR)/, $(addsuffix .bin, $(basename $(
BIN = $(VS_BIN) $(FS_BIN)
ASM = $(VS_ASM) $(FS_ASM)
ifeq ($(TARGET), 1)
ifeq ($(TARGET), $(filter $(TARGET),1 3 4 6))
BIN += $(CS_BIN)
ASM += $(CS_ASM)
else
ifeq ($(TARGET), 3)
BIN += $(CS_BIN)
ASM += $(CS_ASM)
else
ifeq ($(TARGET), 4)
BIN += $(CS_BIN)
ASM += $(CS_ASM)
endif
endif
endif
$(BUILD_INTERMEDIATE_DIR)/vs_%.bin : $(SHADERS_DIR)vs_%.sc

View File

@ -10,7 +10,48 @@
#ifndef __cplusplus
#if BGFX_SHADER_LANGUAGE_HLSL
#if BGFX_SHADER_LANGUAGE_GLSL
#define SHARED shared
#define __IMAGE_XX(_name, _format, _reg, _image, _access) \
layout(_format, binding=_reg) _access uniform highp _image _name
#define readwrite
#define IMAGE2D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, readonly)
#define UIMAGE2D_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, readonly)
#define IMAGE2D_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, writeonly)
#define UIMAGE2D_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, writeonly)
#define IMAGE2D_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, readwrite)
#define UIMAGE2D_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, readwrite)
#define IMAGE2D_ARRAY_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, readonly)
#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, readonly)
#define IMAGE2D_ARRAY_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, writeonly)
#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, writeonly)
#define IMAGE2D_ARRAY_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, readwrite)
#define UIMAGE2D_ARRAY_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, readwrite)
#define IMAGE3D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readonly)
#define UIMAGE3D_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readonly)
#define IMAGE3D_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, writeonly)
#define UIMAGE3D_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, writeonly)
#define IMAGE3D_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readwrite)
#define UIMAGE3D_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readwrite)
#define __BUFFER_XX(_name, _type, _reg, _access) \
layout(std430, binding=_reg) _access buffer _name ## Buffer \
{ \
_type _name[]; \
}
#define BUFFER_RO(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readonly)
#define BUFFER_RW(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readwrite)
#define BUFFER_WR(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, writeonly)
#define NUM_THREADS(_x, _y, _z) layout (local_size_x = _x, local_size_y = _y, local_size_z = _z) in;
#else
#define SHARED groupshared
@ -23,29 +64,29 @@
#define rgba8 float4
#define rgba32f float4
#define IMAGE2D_RO( _name, _format, _reg) Texture2D<_format> _name : register(t[_reg])
#define UIMAGE2D_RO(_name, _format, _reg) Texture2D<_format> _name : register(t[_reg])
#define IMAGE2D_WR( _name, _format, _reg) RWTexture2D<_format> _name : register(u[_reg])
#define UIMAGE2D_WR(_name, _format, _reg) RWTexture2D<_format> _name : register(u[_reg])
#define IMAGE2D_RW( _name, _format, _reg) RWTexture2D<_format> _name : register(u[_reg])
#define UIMAGE2D_RW(_name, _format, _reg) RWTexture2D<_format> _name : register(u[_reg])
#define IMAGE2D_RO( _name, _format, _reg) Texture2D<_format> _name : REGISTER(t, _reg)
#define UIMAGE2D_RO(_name, _format, _reg) Texture2D<_format> _name : REGISTER(t, _reg)
#define IMAGE2D_WR( _name, _format, _reg) RWTexture2D<_format> _name : REGISTER(u, _reg)
#define UIMAGE2D_WR(_name, _format, _reg) RWTexture2D<_format> _name : REGISTER(u, _reg)
#define IMAGE2D_RW( _name, _format, _reg) RWTexture2D<_format> _name : REGISTER(u, _reg)
#define UIMAGE2D_RW(_name, _format, _reg) RWTexture2D<_format> _name : REGISTER(u, _reg)
#define IMAGE2D_ARRAY_RO( _name, _format, _reg) Texture2DArray<_format> _name : register(t[_reg])
#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) Texture2DArray<_format> _name : register(t[_reg])
#define IMAGE2D_ARRAY_WR( _name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
#define IMAGE2D_ARRAY_RW( _name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
#define UIMAGE2D_ARRAY_RW(_name, _format, _reg) RWTexture2DArray<_format> _name : register(u[_reg])
#define IMAGE2D_ARRAY_RO( _name, _format, _reg) Texture2DArray<_format> _name : REGISTER(t, _reg)
#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) Texture2DArray<_format> _name : REGISTER(t, _reg)
#define IMAGE2D_ARRAY_WR( _name, _format, _reg) RWTexture2DArray<_format> _name : REGISTER(u, _reg)
#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) RWTexture2DArray<_format> _name : REGISTER(u, _reg)
#define IMAGE2D_ARRAY_RW( _name, _format, _reg) RWTexture2DArray<_format> _name : REGISTER(u, _reg)
#define UIMAGE2D_ARRAY_RW(_name, _format, _reg) RWTexture2DArray<_format> _name : REGISTER(u, _reg)
#define IMAGE3D_RO( _name, _format, _reg) Texture3D<_format> _name : register(t[_reg])
#define UIMAGE3D_RO(_name, _format, _reg) Texture3D<_format> _name : register(t[_reg])
#define IMAGE3D_WR( _name, _format, _reg) RWTexture3D<_format> _name : register(u[_reg])
#define UIMAGE3D_WR(_name, _format, _reg) RWTexture3D<_format> _name : register(u[_reg])
#define IMAGE3D_RW( _name, _format, _reg) RWTexture3D<_format> _name : register(u[_reg])
#define UIMAGE3D_RW(_name, _format, _reg) RWTexture3D<_format> _name : register(u[_reg])
#define IMAGE3D_RO( _name, _format, _reg) Texture3D<_format> _name : REGISTER(t, _reg)
#define UIMAGE3D_RO(_name, _format, _reg) Texture3D<_format> _name : REGISTER(t, _reg)
#define IMAGE3D_WR( _name, _format, _reg) RWTexture3D<_format> _name : REGISTER(u, _reg)
#define UIMAGE3D_WR(_name, _format, _reg) RWTexture3D<_format> _name : REGISTER(u, _reg)
#define IMAGE3D_RW( _name, _format, _reg) RWTexture3D<_format> _name : REGISTER(u, _reg)
#define UIMAGE3D_RW(_name, _format, _reg) RWTexture3D<_format> _name : REGISTER(u, _reg)
#define BUFFER_RO(_name, _struct, _reg) Buffer<_struct> _name : register(t[_reg])
#define BUFFER_RW(_name, _struct, _reg) RWBuffer<_struct> _name : register(u[_reg])
#define BUFFER_RO(_name, _struct, _reg) Buffer<_struct> _name : REGISTER(t, _reg)
#define BUFFER_RW(_name, _struct, _reg) RWBuffer<_struct> _name : REGISTER(u, _reg)
#define BUFFER_WR(_name, _struct, _reg) BUFFER_RW(_name, _struct, _reg)
#define NUM_THREADS(_x, _y, _z) [numthreads(_x, _y, _z)]
@ -59,11 +100,11 @@
void imageStore( RWTexture2D<_textureType> _image, ivec2 _uv, _type _value) { _image[_uv ] = _value._storeComponents; } \
void imageStore(RWTexture2DArray<_textureType> _image, ivec3 _uvw, _type _value) { _image[_uvw] = _value._storeComponents; } \
void imageStore( RWTexture3D<_textureType> _image, ivec3 _uvw, _type _value) { _image[_uvw] = _value._storeComponents; } \
ivec2 imageSize( Texture2D<_textureType> _image) { ivec2 result; _image.GetDimensions(result.x, result.y); return result; } \
ivec2 imageSize( RWTexture2D<_textureType> _image) { ivec2 result; _image.GetDimensions(result.x, result.y); return result; } \
ivec3 imageSize(RWTexture2DArray<_textureType> _image) { ivec3 result; _image.GetDimensions(result.x, result.y, result.z); return result; } \
ivec3 imageSize( Texture3D<_textureType> _image) { ivec3 result; _image.GetDimensions(result.x, result.y, result.z); return result; } \
ivec3 imageSize( RWTexture3D<_textureType> _image) { ivec3 result; _image.GetDimensions(result.x, result.y, result.z); return result; }
ivec2 imageSize( Texture2D<_textureType> _image) { uvec2 result; _image.GetDimensions(result.x, result.y); return ivec2(result); } \
ivec2 imageSize( RWTexture2D<_textureType> _image) { uvec2 result; _image.GetDimensions(result.x, result.y); return ivec2(result); } \
ivec3 imageSize(RWTexture2DArray<_textureType> _image) { uvec3 result; _image.GetDimensions(result.x, result.y, result.z); return ivec3(result); } \
ivec3 imageSize( Texture3D<_textureType> _image) { uvec3 result; _image.GetDimensions(result.x, result.y, result.z); return ivec3(result); } \
ivec3 imageSize( RWTexture3D<_textureType> _image) { uvec3 result; _image.GetDimensions(result.x, result.y, result.z); return ivec3(result); }
__IMAGE_IMPL(float, x, vec4, xxxx)
__IMAGE_IMPL(vec2, xy, vec4, xyyy)
@ -122,48 +163,7 @@ uint atomicCompSwap(uint _mem, uint _compare, uint _data)
#define memoryBarrierShared() GroupMemoryBarrierWithGroupSync()
#define groupMemoryBarrier() GroupMemoryBarrierWithGroupSync()
#else
#define SHARED shared
#define __IMAGE_XX(_name, _format, _reg, _image, _access) \
layout(_format, binding=_reg) _access uniform highp _image _name
#define readwrite
#define IMAGE2D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, readonly)
#define UIMAGE2D_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, readonly)
#define IMAGE2D_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, writeonly)
#define UIMAGE2D_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, writeonly)
#define IMAGE2D_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2D, readwrite)
#define UIMAGE2D_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2D, readwrite)
#define IMAGE2D_ARRAY_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, readonly)
#define UIMAGE2D_ARRAY_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, readonly)
#define IMAGE2D_ARRAY_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, writeonly)
#define UIMAGE2D_ARRAY_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, writeonly)
#define IMAGE2D_ARRAY_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image2DArray, readwrite)
#define UIMAGE2D_ARRAY_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage2DArray, readwrite)
#define IMAGE3D_RO( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readonly)
#define UIMAGE3D_RO(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readonly)
#define IMAGE3D_WR( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, writeonly)
#define UIMAGE3D_WR(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, writeonly)
#define IMAGE3D_RW( _name, _format, _reg) __IMAGE_XX(_name, _format, _reg, image3D, readwrite)
#define UIMAGE3D_RW(_name, _format, _reg) __IMAGE_XX(_name, _format, _reg, uimage3D, readwrite)
#define __BUFFER_XX(_name, _type, _reg, _access) \
layout(std430, binding=_reg) _access buffer _name ## Buffer \
{ \
_type _name[]; \
}
#define BUFFER_RO(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readonly)
#define BUFFER_RW(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, readwrite)
#define BUFFER_WR(_name, _type, _reg) __BUFFER_XX(_name, _type, _reg, writeonly)
#define NUM_THREADS(_x, _y, _z) layout (local_size_x = _x, local_size_y = _y, local_size_z = _z) in;
#endif // BGFX_SHADER_LANGUAGE_HLSL
#endif // BGFX_SHADER_LANGUAGE_GLSL
#define dispatchIndirect(_buffer \
, _offset \

View File

@ -17,7 +17,7 @@ extern "C"
#define BGFX_CHUNK_MAGIC_VSH BX_MAKEFOURCC('V', 'S', 'H', 0x4)
#define BGFX_SHADERC_VERSION_MAJOR 1
#define BGFX_SHADERC_VERSION_MINOR 0
#define BGFX_SHADERC_VERSION_MINOR 1
namespace bgfx
{