Draw: Add COLOR1 semantic.

This commit is contained in:
Unknown W. Brackets committed 2022-10-01 12:14:46 -07:00
1 parent 16f93a2684
commit 59a489f883
11 files changed
+23 -23

No files matched your search

+1
View File
@@ -686,6 +686,7 @@ const char *semanticToD3D11(int semantic, UINT *index) {
switch (semantic) {
case SEM_POSITION: return "POSITION";
case SEM_COLOR0: *index = 0; return "COLOR";
case SEM_COLOR1: *index = 1; return "COLOR";
case SEM_TEXCOORD0: *index = 0; return "TEXCOORD";
case SEM_TEXCOORD1: *index = 1; return "TEXCOORD";
case SEM_NORMAL: return "NORMAL";
+4
View File
@@ -945,6 +945,10 @@ static void SemanticToD3D9UsageAndIndex(int semantic, BYTE *usage, BYTE *index)
case SEM_COLOR0:
*usage = D3DDECLUSAGE_COLOR;
break;
case SEM_COLOR1:
*usage = D3DDECLUSAGE_COLOR;
*index = 1;
break;
case SEM_TEXCOORD0:
*usage = D3DDECLUSAGE_TEXCOORD;
break;
+1
View File
@@ -1206,6 +1206,7 @@ bool OpenGLPipeline::LinkShaders() {
// Bind all the common vertex data points. Mismatching ones will be ignored.
semantics.push_back({ SEM_POSITION, "Position" });
semantics.push_back({ SEM_COLOR0, "Color0" });
semantics.push_back({ SEM_COLOR1, "Color1" });
semantics.push_back({ SEM_TEXCOORD0, "TexCoord0" });
semantics.push_back({ SEM_NORMAL, "Normal" });
semantics.push_back({ SEM_TANGENT, "Tangent" });
+4 -2
View File
@@ -152,16 +152,18 @@ std::string Postprocess(std::string code, ShaderLanguage lang, ShaderStage stage
return output;
}
static_assert(Draw::SEM_TEXCOORD0 == 3, "Semantic shader hardcoded in glsl below.");
bool ConvertToVulkanGLSL(std::string *dest, TranslatedShaderMetadata *destMetadata, std::string src, ShaderStage stage, std::string *errorMessage) {
std::stringstream out;
static struct {
static const struct {
ShaderStage stage;
const char *needle;
const char *replacement;
} replacements[] = {
{ ShaderStage::Vertex, "attribute vec4 a_position;", "layout(location = 0) in vec4 a_position;" },
{ ShaderStage::Vertex, "attribute vec2 a_texcoord0;", "layout(location = 2) in vec2 a_texcoord0;"},
{ ShaderStage::Vertex, "attribute vec2 a_texcoord0;", "layout(location = 3) in vec2 a_texcoord0;"},
{ ShaderStage::Vertex, "varying vec2 v_position;", "layout(location = 0) out vec2 v_position;" },
{ ShaderStage::Fragment, "varying vec2 v_position;", "layout(location = 0) in vec2 v_position;" },
{ ShaderStage::Fragment, "texture2D(", "texture(" },
+3 -1
View File
@@ -68,15 +68,17 @@ static const char * const hlsl_preamble_vs =
"#define highp\n"
"\n";
static const char * const semanticNames[8] = {
static const char * const semanticNames[] = {
"POSITION",
"COLOR0",
"COLOR1",
"TEXCOORD0",
"TEXCOORD1",
"NORMAL",
"TANGENT",
"BINORMAL",
};
static_assert(ARRAY_SIZE(semanticNames) == Draw::SEM_MAX, "Missing semantic in semanticNames");
// Unsafe. But doesn't matter, we'll use big buffers for shader gen.
ShaderWriter & ShaderWriter::F(const char *format, ...) {
+1 -13
View File
@@ -215,8 +215,8 @@ private:
};
bool VKShaderModule::Compile(VulkanContext *vulkan, ShaderLanguage language, const uint8_t *data, size_t size) {
vulkan_ = vulkan;
// We'll need this to free it later.
vulkan_ = vulkan;
source_ = (const char *)data;
std::vector<uint32_t> spirv;
std::string errorMessage;
@@ -278,7 +278,6 @@ public:
return buf->PushAligned(ubo_, uboSize_, vulkan->GetPhysicalDeviceProperties().properties.limits.minUniformBufferOffsetAlignment, vkbuf);
}
int GetUniformLoc(const char *name);
int GetUBOSize() const {
return uboSize_;
}
@@ -1308,17 +1307,6 @@ ShaderModule *VKContext::CreateShaderModule(ShaderStage stage, ShaderLanguage la
}
}
int VKPipeline::GetUniformLoc(const char *name) {
int loc = -1;
// HACK! As we only use one uniform we hardcode it.
if (!strcmp(name, "WorldViewProj")) {
return 0;
}
return loc;
}
void VKContext::UpdateDynamicUniformBuffer(const void *ub, size_t size) {
curPipeline_->SetDynamicUniformData(ub, size);
}
+3 -1
View File
@@ -435,7 +435,7 @@ vec3 hsv2rgb(vec3 c) {
}
layout (location = 0) in vec4 pos;
layout (location = 1) in vec4 inColor;
layout (location = 2) in vec2 inTexCoord;
layout (location = 3) in vec2 inTexCoord;
layout (location = 0) out vec4 outColor;
layout (location = 1) out vec2 outTexCoord;
out gl_PerVertex { vec4 gl_Position; };
@@ -450,6 +450,8 @@ void main() {
)"
} };
static_assert(SEM_TEXCOORD0 == 3, "Semantic shader hardcoded in glsl above.");
const UniformBufferDesc vsTexColBufDesc{ sizeof(VsTexColUB),{
{ "WorldViewProj", 0, -1, UniformType::MATRIX4X4, 0 },
{ "TintSaturation", 4, -1, UniformType::FLOAT2, 64 },
+1
View File
@@ -114,6 +114,7 @@ enum BufferUsageFlag : int {
enum Semantic : int {
SEM_POSITION,
SEM_COLOR0,
SEM_COLOR1,
SEM_TEXCOORD0,
SEM_TEXCOORD1,
SEM_NORMAL,
-3
View File
@@ -127,9 +127,6 @@ static const char * const boneWeightDecl[9] = {
"layout(location = 3) in vec4 w1;\nlayout(location = 4) in vec4 w2;\n",
};
extern const char *vulkan_glsl_preamble_vs;
extern const char *hlsl_preamble_vs;
bool GenerateVertexShader(const VShaderID &id, char *buffer, const ShaderLanguageDesc &compat, Draw::Bugs bugs, uint32_t *attrMask, uint64_t *uniformMask, std::string *errorString) {
*attrMask = 0;
*uniformMask = 0;
+1 -1
View File
@@ -1144,7 +1144,7 @@ int ShaderListScreen::ListShaders(DebugShaderType shaderType, UI::LinearLayout *
using namespace UI;
std::vector<std::string> shaderIds_ = gpu->DebugGetShaderIDs(shaderType);
int count = 0;
for (auto id : shaderIds_) {
for (const auto &id : shaderIds_) {
Choice *choice = view->Add(new Choice(gpu->DebugGetShaderString(id, shaderType, SHADER_STRING_SHORT_DESC)));
choice->SetTag(id);
choice->OnClick.Handle(this, &ShaderListScreen::OnShaderClick);
+4 -2
View File
@@ -122,7 +122,7 @@ static const std::vector<Draw::ShaderSource> vsAdrenoLogicTest = {
"} myBufferVals;\n"
"layout (location = 0) in vec4 pos;\n"
"layout (location = 1) in vec4 inColor;\n"
"layout (location = 2) in vec2 inTexCoord;\n"
"layout (location = 3) in vec2 inTexCoord;\n"
"layout (location = 0) out vec4 outColor;\n"
"layout (location = 1) out highp vec2 outTexCoord;\n"
"out gl_PerVertex { vec4 gl_Position; };\n"
@@ -219,7 +219,7 @@ static const std::vector<Draw::ShaderSource> vsFlat = {
"} myBufferVals;\n"
"layout (location = 0) in vec4 pos;\n"
"layout (location = 1) in vec4 inColor;\n"
"layout (location = 2) in vec2 inTexCoord;\n"
"layout (location = 3) in vec2 inTexCoord;\n"
"layout (location = 0) flat out lowp vec4 outColor;\n"
"layout (location = 1) out highp vec2 outTexCoord;\n"
"out gl_PerVertex { vec4 gl_Position; };\n"
@@ -231,6 +231,8 @@ static const std::vector<Draw::ShaderSource> vsFlat = {
}
};
static_assert(Draw::SEM_TEXCOORD0 == 3, "Semantic shader hardcoded in glsl above.");
GPUDriverTestScreen::GPUDriverTestScreen() {
using namespace Draw;
}