Skip to content

Commit

Permalink
Added Vulkan sample for PushConstants
Browse files Browse the repository at this point in the history
  • Loading branch information
haing committed Apr 20, 2016
1 parent 8e92daf commit d7d997c
Show file tree
Hide file tree
Showing 50 changed files with 792 additions and 289 deletions.
24 changes: 12 additions & 12 deletions samples/_vulkan/NormalMappingBasic/src/NormalMappingBasicApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,18 +141,18 @@ VkBool32 debugReportVk(
}

const std::vector<std::string> gLayers = {
"VK_LAYER_LUNARG_api_dump",
"VK_LAYER_LUNARG_core_validation",
"VK_LAYER_LUNARG_device_limits",
"VK_LAYER_LUNARG_image",
"VK_LAYER_LUNARG_object_tracker",
"VK_LAYER_LUNARG_parameter_validation",
"VK_LAYER_LUNARG_screenshot",
"VK_LAYER_LUNARG_swapchain",
"VK_LAYER_GOOGLE_threading",
"VK_LAYER_GOOGLE_unique_objects",
"VK_LAYER_LUNARG_vktrace",
"VK_LAYER_LUNARG_standard_validation",
//"VK_LAYER_LUNARG_api_dump",
//"VK_LAYER_LUNARG_core_validation",
//"VK_LAYER_LUNARG_device_limits",
//"VK_LAYER_LUNARG_image",
//"VK_LAYER_LUNARG_object_tracker",
//"VK_LAYER_LUNARG_parameter_validation",
//"VK_LAYER_LUNARG_screenshot",
//"VK_LAYER_LUNARG_swapchain",
//"VK_LAYER_GOOGLE_threading",
//"VK_LAYER_GOOGLE_unique_objects",
//"VK_LAYER_LUNARG_vktrace",
//"VK_LAYER_LUNARG_standard_validation",
};

CINDER_APP(
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 12 additions & 0 deletions samples/_vulkan/PushConstants/assets/shader_color.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#version 150
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(location = 0) in vec4 Color;

layout(location = 0) out vec4 oColor;

void main( void )
{
oColor = Color;
}
24 changes: 24 additions & 0 deletions samples/_vulkan/PushConstants/assets/shader_color.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#version 150
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(push_constant) uniform ciBlock0T {
mat4 ciModelViewProjection;
vec2 ciRect[2];
vec2 ciTexCoord[2];
vec4 ciColor;
} ciBlock0;

layout(location = 0) in vec4 ciPosition;

layout(location = 0) out vec4 Color;

void main( void )
{
float x = mix( ciBlock0.ciRect[0].x, ciBlock0.ciRect[1].x, ciPosition.x );
float y = mix( ciBlock0.ciRect[0].y, ciBlock0.ciRect[1].y, ciPosition.y );
vec4 pos = vec4( x, y, ciPosition.zw );
gl_Position = ciBlock0.ciModelViewProjection * pos;

Color = ciBlock0.ciColor;
}
15 changes: 15 additions & 0 deletions samples/_vulkan/PushConstants/assets/shader_tex.frag
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#version 150
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(binding = 0) uniform sampler2D uTex0;

layout(location = 0) in vec2 TexCoord;
layout(location = 1) in vec4 Color;

layout(location = 0) out vec4 oColor;

void main( void )
{
oColor = texture( uTex0, TexCoord );
}
29 changes: 29 additions & 0 deletions samples/_vulkan/PushConstants/assets/shader_tex.vert
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#version 150
#extension GL_ARB_separate_shader_objects : enable
#extension GL_ARB_shading_language_420pack : enable

layout(push_constant) uniform ciBlock0T {
mat4 ciModelViewProjection;
vec2 ciRect[2];
vec2 ciTexCoord[2];
vec4 ciColor;
} ciBlock0;

layout(location = 0) in vec4 ciPosition;

layout(location = 0) out vec2 TexCoord;
layout(location = 1) out vec4 Color;

void main( void )
{
float x = mix( ciBlock0.ciRect[0].x, ciBlock0.ciRect[1].x, ciPosition.x );
float y = mix( ciBlock0.ciRect[0].y, ciBlock0.ciRect[1].y, ciPosition.y );
vec4 pos = vec4( x, y, ciPosition.zw );
gl_Position = ciBlock0.ciModelViewProjection * pos;

float u = mix( ciBlock0.ciTexCoord[0].x, ciBlock0.ciTexCoord[1].x, ciPosition.x );
float v = mix( ciBlock0.ciTexCoord[0].y, ciBlock0.ciTexCoord[1].y, ciPosition.y );
TexCoord = vec2( u, v );

Color = ciBlock0.ciColor;
}
7 changes: 7 additions & 0 deletions samples/_vulkan/PushConstants/include/Resources.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include "cinder/CinderResources.h"

//#define RES_MY_RES CINDER_RESOURCE( ../resources/, image_name.png, 128, IMAGE )



Binary file not shown.
Loading

0 comments on commit d7d997c

Please sign in to comment.