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