Skip to content

Commit

Permalink
[rhi/mtl] command context update
Browse files Browse the repository at this point in the history
add ios build

iOS: add Info.plist generator

[core/module] fix static linked module impl

[core] impl query cpu usage

[rhi/mtl] add display link to metal view

[core/string] add hash function for String

[ios] add notification to loop the renderer

[rhi/mtl] correct ios pixel format on metal layer

remove interfaces

update ios plist_gen

[rhi/mtl] update metal rhi

[render] add font renderer #38

[vk] upload texture directly with linear tiling option

[android] fix build error caused by freetype

[and] fix android compilation

[vk] load device procs at runtime

[vk] fix memory leaks

[render] add font shaders

[vk] refactor

[vk] fix bugs

[vk] refactor finished

fix include path in core headers

[rhi/mtl] make format of render target consistent with fragment shader output

[rhi/mtl] disable arc

[rhi] replace `VertexInputLayout` with `VertexInputState`

unify shader binding across vk and mtl

[tools] add visualstudio visualizer

[unittest]add hlsl shader for triangle unit test

[rhi] add hlsl shader test case

[vk/hlsl] fix hlsl textured cube sample

[vk/hlsl] merge image & sampler combination

[rhi/unittest] add compute particles unit test

[core/unittest] update core unit test

[vk] update vk function entry initializer

[ktl/sp] fix dual-free error of ref count instance #42

[vk] refactored vulkan resource

[interface] update RHI

[win] add vs2017 support

[ktl] add sharedptr ref count tracker #43

fix clang build error caused by 'typedef uint64 VkObject..'
  • Loading branch information
Tomicyo committed Mar 18, 2017
1 parent f81e444 commit 3684c95
Show file tree
Hide file tree
Showing 232 changed files with 6,919 additions and 4,107 deletions.
3 changes: 1 addition & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ osx_image: xcode8.1

install:
- brew install cmake
- git clone https://github.com/Tomicyo/kaleido3d_dep_prebuilt.git -b macos_debug Source/ThirdParty_Prebuilt/MacOS_Debug

script:
- chmod 777 make_macos.sh && ./make_macos.sh
- chmod 777 make_macos.sh && ./make_macos.sh
8 changes: 8 additions & 0 deletions Data/Test/TextRender.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#version 430
layout (location = 0) in vec2 inCoord;
layout (location = 0) out vec4 outFragColor;
uniform sampler2D fontTex;
void main()
{
outFragColor = texture(fontTex, inCoord);
}
13 changes: 13 additions & 0 deletions Data/Test/TextRender.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#version 430
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec2 inCoord;
layout (location = 0) out vec2 outCoord;
out gl_PerVertex
{
vec4 gl_Position;
};
void main()
{
outCoord = inCoord;
gl_Position = vec4(inPos, 1.0);
}
Binary file added Data/Test/calibri.ttf
Binary file not shown.
22 changes: 21 additions & 1 deletion Data/Test/cube.frag
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define USE_GLSL 0
#if USE_GLSL
#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
Expand All @@ -10,4 +12,22 @@ layout (location = 1) in vec2 uv;
layout (location = 0) out vec4 uFragColor;
void main() {
uFragColor = texture(tex, uv) * color;
}
}
#else

SamplerState samp : register(s1);
Texture2D<float4> tex : register(t1);

struct PS_IN
{
// float4 outPos: SV_POSITION;
float4 outColor: COLOR;
float2 outCoord: TEXCOORD0;
};

float4 main(PS_IN ps_in) : SV_TARGET
{
return tex.Sample(samp, ps_in.outCoord);
}

#endif
41 changes: 40 additions & 1 deletion Data/Test/cube.vert
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define USE_GLSL 0

#if USE_GLSL

#version 400
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable
Expand All @@ -20,4 +24,39 @@ void main() {
color = vertColor;
uv = vertUV;
gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(pos, 1.0f);
}
}

#else

cbuffer UBO : register(b0)
{
row_major matrix projectMatrix;
row_major matrix modelMatrix;
row_major matrix viewMatrix;
};

struct VS_IN
{
float3 pos : POSITION;
float4 vertColor: COLOR;
float2 vertUV: TEXCOORD0;
};

struct VS_OUT
{
float4 outPos: SV_POSITION;
float4 outColor: COLOR;
float2 outCoord: TEXCOORD0;
};

VS_OUT main(VS_IN vs_in)
{
VS_OUT vs_out;
vs_out.outPos = projectMatrix * viewMatrix * modelMatrix * float4(vs_in.pos, 1.0);
vs_out.outColor = vs_in.vertColor;
vs_out.outCoord = vs_in.vertUV;
return vs_out;
}


#endif
95 changes: 95 additions & 0 deletions Data/Test/particles.comp
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
#define USE_GLSL 0

#if USE_GLSL

#version 430

layout (std140, binding = 0) uniform attractor_block
{
vec4 attractor[64]; // xyz = position, w = mass
};

layout (local_size_x = 1024) in;

layout (rgba32f, binding = 0) uniform imageBuffer velocity_buffer;
layout (rgba32f, binding = 1) uniform imageBuffer position_buffer;

uniform float dt = 1.0;

void main(void)
{
vec4 vel = imageLoad(velocity_buffer, int(gl_GlobalInvocationID.x));
vec4 pos = imageLoad(position_buffer, int(gl_GlobalInvocationID.x));

int i;

pos.xyz += vel.xyz * dt;
pos.w -= 0.0001 * dt;

for (i = 0; i < 4; i++)
{
vec3 dist = (attractor[i].xyz - pos.xyz);
vel.xyz += dt * dt * attractor[i].w * normalize(dist) / (dot(dist, dist) + 10.0);
}

if (pos.w <= 0.0)
{
pos.xyz = -pos.xyz * 0.01;
vel.xyz *= 0.01;
pos.w += 1.0f;
}

imageStore(position_buffer, int(gl_GlobalInvocationID.x), pos);
imageStore(velocity_buffer, int(gl_GlobalInvocationID.x), vel);
}

#else

#define blocksize 64

groupshared float4 attractor[blocksize];

cbuffer cbCS : register(b0)
{
float dt;
};

//RWStructuredBuffer<float4> velocity_buffer : register(u0); // UAV
//RWStructuredBuffer<float4> position_buffer : register(u1); // UAV

RWTexture1D <float4> velocity_buffer : register(t0);
RWTexture1D <float4> position_buffer : register(t1);

[numthreads(1024, 1, 1)]
void main(
uint3 Gid : SV_GroupID,
uint3 DTid : SV_DispatchThreadID,
uint3 GTid : SV_GroupThreadID,
uint GI : SV_GroupIndex)
{
float4 vel = velocity_buffer.Load(DTid.x);
float4 pos = position_buffer.Load(DTid.x);

int i;

pos.xyz += vel.xyz * dt;
pos.w -= 0.0001 * dt;

for (i = 0; i < 4; i++)
{
float3 dist = (attractor[i].xyz - pos.xyz);
vel.xyz += dt * dt * attractor[i].w * normalize(dist) / (dot(dist, dist) + 10.0);
}

if (pos.w <= 0.0)
{
pos.xyz = -pos.xyz * 0.01;
vel.xyz *= 0.01;
pos.w += 1.0f;
}

position_buffer[DTid.x] = pos;
velocity_buffer[DTid.x] = vel;
}

#endif
25 changes: 25 additions & 0 deletions Data/Test/particles.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#define USE_GLSL 0

#if USE_GLSL

#version 430
layout (location = 0) out vec4 color;
in float intensity;
void main(void)
{
color = mix(vec4(0.0f, 0.2f, 1.0f, 1.0f), vec4(0.2f, 0.05f, 0.0f, 1.0f), intensity);
}

#else

struct PS_IN
{
float intensity : INTENSITY;
};

float4 main(PS_IN ps_in) : SV_Target
{
return lerp(float4(0.0f, 0.2f, 1.0f, 1.0f), float4(0.2f, 0.05f, 0.0f, 1.0f), ps_in.intensity);
}

#endif
41 changes: 41 additions & 0 deletions Data/Test/particles.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#define USE_GLSL 0

#if USE_GLSL

#version 430
in vec4 vert;
uniform mat4 mvp;
out float intensity;
void main(void)
{
intensity = vert.w;
gl_Position = mvp * vec4(vert.xyz, 1.0);
}

#else

struct VS_IN
{
float4 vert : POSITION;
};

cbuffer mat : register(b0)
{
row_major matrix mvp;
};

struct VS_OUT
{
float4 outPos : SV_POSITION;
float intensity : INTENSITY;
};

VS_OUT main(VS_IN vs_in)
{
VS_OUT vs_out;
vs_out.outPos = mvp * float4(vs_in.vert.xyz, 1.0);
vs_out.intensity = vs_in.vert.w;
return vs_out;
}

#endif
18 changes: 18 additions & 0 deletions Data/Test/triangle.frag
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define USE_GLSL 0

#if USE_GLSL

#version 430

#extension GL_ARB_separate_shader_objects : enable
Expand All @@ -11,3 +15,17 @@ void main()
{
outFragColor = vec4(inColor, 1.0);
}

#else

struct VS_OUT
{
// float4 outPos : SV_POSITION;
float3 outColor: COLOR;
};

float4 main(VS_OUT psIn) : SV_TARGET {
return float4(psIn.outColor, 1.0);
}

#endif
46 changes: 41 additions & 5 deletions Data/Test/triangle.vert
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
#define USE_GLSL 0

#if USE_GLSL

#version 430

#extension GL_ARB_separate_shader_objects : enable
Expand All @@ -6,7 +10,7 @@
layout (location = 0) in vec3 inPos;
layout (location = 1) in vec3 inColor;

layout (binding = 0) uniform UBO
layout (binding = 0) uniform UBO
{
mat4 projectionMatrix;
mat4 modelMatrix;
Expand All @@ -15,14 +19,46 @@ layout (binding = 0) uniform UBO

layout (location = 0) out vec3 outColor;

out gl_PerVertex
out gl_PerVertex
{
vec4 gl_Position;
vec4 gl_Position;
};


void main()
void main()
{
outColor = inColor;
gl_Position = ubo.projectionMatrix * ubo.viewMatrix * ubo.modelMatrix * vec4(inPos.xyz, 1.0);
}
}

#else

#pragma pack_matrix( row_major )

struct VS_IN
{
float3 inPos : POSITION;
float3 inColor : COLOR;
};

struct VS_OUT
{
float4 outPos : SV_POSITION;
float3 outColor : COLOR;
};

cbuffer UBO : register(b0)
{
row_major matrix projectMatrix;
row_major matrix modelMatrix;
row_major matrix viewMatrix;
};

VS_OUT main(VS_IN vsin)
{
VS_OUT vsout;
vsout.outPos = projectMatrix * viewMatrix * modelMatrix * float4(vsin.inPos.xyz, 1.0);
vsout.outColor = vsin.inColor;
return vsout;
}
#endif
2 changes: 2 additions & 0 deletions Include/Config/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

The "stdint.h" header is copied from llvm-3.5
1 change: 0 additions & 1 deletion Include/Config/note.txt

This file was deleted.

Loading

0 comments on commit 3684c95

Please sign in to comment.