2017-07-19 23:25:24 -06:00
|
|
|
// Copyright 2017 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2+
|
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-11-22 15:10:41 -07:00
|
|
|
#include <string>
|
|
|
|
#include <string_view>
|
|
|
|
|
|
|
|
#include <fmt/format.h>
|
|
|
|
|
2019-12-22 11:40:40 -07:00
|
|
|
#include "Common/CommonTypes.h"
|
|
|
|
|
|
|
|
class ShaderCode;
|
|
|
|
enum class APIType;
|
|
|
|
union ShaderHostConfig;
|
2017-07-19 23:25:24 -06:00
|
|
|
|
|
|
|
namespace UberShader
|
|
|
|
{
|
|
|
|
// Common functions across all ubershaders
|
|
|
|
void WriteUberShaderCommonHeader(ShaderCode& out, APIType api_type,
|
|
|
|
const ShaderHostConfig& host_config);
|
|
|
|
|
2017-07-27 04:52:20 -06:00
|
|
|
// Vertex lighting
|
|
|
|
void WriteLightingFunction(ShaderCode& out);
|
|
|
|
void WriteVertexLighting(ShaderCode& out, APIType api_type, const char* world_pos_var,
|
|
|
|
const char* normal_var, const char* in_color_0_var,
|
|
|
|
const char* in_color_1_var, const char* out_color_0_var,
|
|
|
|
const char* out_color_1_var);
|
|
|
|
|
2017-07-19 23:25:24 -06:00
|
|
|
// bitfieldExtract generator for BitField types
|
|
|
|
template <typename T>
|
2019-11-22 15:10:41 -07:00
|
|
|
std::string BitfieldExtract(std::string_view source, T type)
|
2017-07-19 23:25:24 -06:00
|
|
|
{
|
2019-11-22 15:10:41 -07:00
|
|
|
return fmt::format("bitfieldExtract({}, {}, {})", source, static_cast<u32>(type.StartBit()),
|
|
|
|
static_cast<u32>(type.NumBits()));
|
2017-07-19 23:25:24 -06:00
|
|
|
}
|
|
|
|
} // namespace UberShader
|