Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1575,7 +1575,7 @@ else()
endif()

if(WIN32)
target_link_libraries(Common winmm dsound dxguid Version)
target_link_libraries(Common winmm dsound dxguid d2d1 dwrite d3d11 Version)
endif()

if(NOT LIBRETRO)
Expand Down Expand Up @@ -2952,6 +2952,9 @@ if(HEADLESS)
endif()
add_executable(PPSSPPHeadless ${HeadlessSource})
target_link_libraries(PPSSPPHeadless ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY} ${LinkCommon})
if(WIN32)
target_link_libraries(PPSSPPHeadless d2d1 dwrite d3d11)
endif()
setup_target_project(PPSSPPHeadless headless)
endif()

Expand Down Expand Up @@ -2980,6 +2983,9 @@ if(UNITTEST)
)
endif()
target_link_libraries(PPSSPPUnitTest ${COCOA_LIBRARY} ${QUARTZ_CORE_LIBRARY} ${IOKIT_LIBRARY} ${LinkCommon} Common)
if(WIN32)
target_link_libraries(PPSSPPUnitTest d2d1 dwrite d3d11)
endif()
setup_target_project(PPSSPPUnitTest unittest)
add_test(arm64_emitter PPSSPPUnitTest Arm64Emitter)
add_test(arm_emitter PPSSPPUnitTest ArmEmitter)
Expand Down
2 changes: 1 addition & 1 deletion Common/Arm64Emitter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1953,7 +1953,7 @@ static int Count(const bool part[4]) {
void ARM64XEmitter::MOVI2R(ARM64Reg Rd, u64 imm, bool optimize)
{
unsigned int parts = Is64Bit(Rd) ? 4 : 2;
bool upload_part[4];
bool upload_part[4]{};

// Always start with a movz! Kills the dependency on the register.
bool use_movz = true;
Expand Down
6 changes: 4 additions & 2 deletions Common/GPU/D3D11/thin3d_d3d11.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
#include "Common/Data/Encoding/Utf8.h"
#include "Common/TimeUtil.h"
#include "Common/Log.h"
#include "Common/StringUtils.h"

#include <map>

Expand Down Expand Up @@ -149,7 +150,6 @@ class D3D11DrawContext : public DrawContext {
stencilDirty_ = true;
}


void Draw(int vertexCount, int offset) override;
void DrawIndexed(int indexCount, int offset) override;
void DrawUP(const void *vdata, int vertexCount) override;
Expand Down Expand Up @@ -1125,7 +1125,9 @@ ShaderModule *D3D11DrawContext::CreateShaderModule(ShaderStage stage, ShaderLang
}
if (errorMsgs) {
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
ERROR_LOG(Log::G3D, "Failed compiling %s:\n%s\n%s", tag, data, errors.c_str());
ERROR_LOG(Log::G3D, "Failed compiling %s:", tag);
ERROR_LOG(Log::G3D, "%s", LineNumberString(std::string((const char *)data, dataSize)).c_str());
ERROR_LOG(Log::G3D, "%s", errors.c_str());
}

if (result != S_OK) {
Expand Down
1 change: 0 additions & 1 deletion Common/GPU/MiscTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ constexpr size_t FRAME_TIME_HISTORY_LENGTH = 32;

// Different APIs use different coordinate conventions
enum class CoordConvention {
Direct3D9,
Direct3D11,
Vulkan,
OpenGL,
Expand Down
69 changes: 44 additions & 25 deletions Common/GPU/ShaderWriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,20 @@ const char * const hlsl_preamble_fs =
"#define ivec4 int4\n"
"#define mat4 float4x4\n"
"#define mat3x4 float4x3\n" // note how the conventions are backwards
"#define splat3(x) float3(x, x, x)\n"
"#define mix lerp\n"
"#define lowp\n"
"#define mediump\n"
"#define highp\n"
"#define splat3(x) float3(x, x, x)\n"
"#define mix lerp\n"
"#define fract frac\n"
"#define mod(x, y) fmod(x, y)\n"
"#define inversesqrt rsqrt\n";
"#define inversesqrt rsqrt\n"
"\n";

static const char * const hlsl_d3d11_preamble_fs =
"#define DISCARD discard\n"
"#define DISCARD_BELOW(x) clip(x);\n";
"#define DISCARD_BELOW(x) clip(x);\n"
"\n";

static const char * const vulkan_glsl_preamble_vs =
"#extension GL_ARB_separate_shader_objects : enable\n"
Expand Down Expand Up @@ -82,10 +84,13 @@ static const char * const hlsl_preamble_vs =
"#define mat2 float2x2\n"
"#define mat4 float4x4\n"
"#define mat3x4 float4x3\n" // note how the conventions are backwards
"#define splat3(x) vec3(x, x, x)\n"
"#define lowp\n"
"#define mediump\n"
"#define highp\n"
"#define splat3(x) float3(x, x, x)\n"
"#define mix lerp\n"
"#define fract frac\n"
"#define mod(x, y) fmod(x, y)\n"
"#define inversesqrt rsqrt\n"
"\n";

Expand Down Expand Up @@ -196,7 +201,40 @@ void ShaderWriter::Preamble(Slice<const char *> extensions) {
}
}

void ShaderWriter::DeclareUniforms(const Slice<UniformDef> &uniforms) {
switch (lang_.shaderLanguage) {
case HLSL_D3D11:
if (!uniforms.is_empty()) {
C("cbuffer base : register(b0) {\n");

for (auto &uniform : uniforms) {
F(" %s %s;\n", uniform.type, uniform.name);
}

C("};\n");
}
break;
case GLSL_VULKAN:
if (!uniforms.is_empty()) {
C("layout(std140, set = 0, binding = 0) uniform bufferVals {\n");
for (auto &uniform : uniforms) {
F("%s %s;\n", uniform.type, uniform.name);
}
C("};\n");
}
break;

default: // GLSL OpenGL
for (auto &uniform : uniforms) {
F("uniform %s %s;\n", uniform.type, uniform.name);
}
break;
}
}

void ShaderWriter::BeginVSMain(Slice<InputDef> inputs, Slice<UniformDef> uniforms, Slice<VaryingDef> varyings) {
DeclareUniforms(uniforms);

_assert_(this->stage_ == ShaderStage::Vertex);
switch (lang_.shaderLanguage) {
case HLSL_D3D11:
Expand Down Expand Up @@ -249,18 +287,9 @@ void ShaderWriter::BeginVSMain(Slice<InputDef> inputs, Slice<UniformDef> uniform

void ShaderWriter::BeginFSMain(Slice<UniformDef> uniforms, Slice<VaryingDef> varyings) {
_assert_(this->stage_ == ShaderStage::Fragment);
DeclareUniforms(uniforms);
switch (lang_.shaderLanguage) {
case HLSL_D3D11:
if (!uniforms.is_empty()) {
C("cbuffer base : register(b0) {\n");

for (auto &uniform : uniforms) {
F(" %s %s;\n", uniform.type, uniform.name);
}

C("};\n");
}

if (flags_ & ShaderWriterFlags::FS_WRITE_DEPTH) {
C("float gl_FragDepth;\n");
}
Expand Down Expand Up @@ -291,23 +320,13 @@ void ShaderWriter::BeginFSMain(Slice<UniformDef> uniforms, Slice<VaryingDef> var
F("layout(location = %d) %s in %s %s; // %s\n", varying.index, varying.precision ? varying.precision : "", varying.type, varying.name, semanticNames[varying.semantic]);
}
C("layout(location = 0, index = 0) out vec4 fragColor0;\n");
if (!uniforms.is_empty()) {
C("layout(std140, set = 0, binding = 0) uniform bufferVals {\n");
for (auto &uniform : uniforms) {
F("%s %s;\n", uniform.type, uniform.name);
}
C("};\n");
}
C("\nvoid main() {\n");
break;

default: // GLSL OpenGL
for (auto &varying : varyings) {
F("%s %s %s %s; // %s\n", lang_.varying_fs, varying.precision ? varying.precision : "", varying.type, varying.name, semanticNames[varying.semantic]);
}
for (auto &uniform : uniforms) {
F("uniform %s %s;\n", uniform.type, uniform.name);
}
if (!strcmp(lang_.fragColor0, "fragColor0")) {
C("out vec4 fragColor0;\n");
}
Expand Down
1 change: 1 addition & 0 deletions Common/GPU/ShaderWriter.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ class ShaderWriter {
// Several of the shader languages ignore samplers, beware of that.
void DeclareSampler2D(const SamplerDef &def);
void DeclareTexture2D(const SamplerDef &def);
void DeclareUniforms(const Slice<UniformDef> &uniforms);
const SamplerDef *GetSamplerDef(const char *name) const;

void Preamble(Slice<const char *> extensions);
Expand Down
Loading
Loading