Created
September 27, 2018 22:18
-
-
Save Vild/3e5b81a294e3d99494de7279994e5ace to your computer and use it in GitHub Desktop.
Vulkan code that I threw away :c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum DataRate { | |
vertex, | |
instance | |
} | |
struct ShaderData(T_, size_t BitsPerChannel_, string Channels_, ChannelFormat Format_) { | |
alias T = T_; | |
alias BitsPerChannel = BitsPerChannel_; | |
alias Channels = Channels_; | |
alias Format = Format_; | |
T data; | |
alias data this; | |
} | |
enum ChannelFormat { | |
uNORM, // 0.0f -> 1.0f | |
sNORM, // -1.0f -> 1.0f | |
//uSCALED, | |
//sSCALED, | |
uINT, | |
sINT, | |
sRGB, // Like UNORM but in sRGB space | |
sFLOAT, // BitsPerChannel == 16 || BitsPerChannel == 32 || BitsPerChannel == 64 | |
//uFLOAT, | |
} | |
private static VkFormat getFormat(size_t channelCount, SD : ShaderData!(T, BitsPerChannel, Channels, Format), T, | |
size_t BitsPerChannel, string Channels, ChannelFormat Format)() { | |
import std.traits : EnumMembers; | |
import std.conv : text; | |
import std.uni : toUpper; | |
enum channels = () { | |
string output; | |
static foreach (c; Channels) { | |
output ~= c; | |
output ~= text(BitsPerChannel); | |
} | |
return output; | |
}(); | |
enum format = text(Format).toUpper; | |
return mixin("VK_FORMAT_" ~ channels ~ "_" ~ format); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment