mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Make the first generated D3D11 shaders compile, fix various warnings
This commit is contained in:
parent
76587ec61c
commit
01f46e7a5d
9 changed files with 69 additions and 39 deletions
|
@ -60,24 +60,25 @@ R"( mat4 proj_mtx;
|
|||
vec2 texclampoff;
|
||||
)";
|
||||
|
||||
// HLSL code is shared so these names are changed to match those in DX9.
|
||||
static const char *cb_baseStr =
|
||||
R"( matrix proj_mtx;
|
||||
matrix proj_through_mtx;
|
||||
matrix view_mtx;
|
||||
matrix world_mtx;
|
||||
matrix tex_mtx;
|
||||
float4 uvscaleoffset;
|
||||
float4 depthRange;
|
||||
float3 fogcoef_stencilreplace;
|
||||
float4 matambientalpha;
|
||||
float3 fogcolor;
|
||||
float3 texenv;
|
||||
ifloat4 alphacolorref;
|
||||
ifloat4 alphacolormask;
|
||||
float3 blendFixA;
|
||||
float3 blendFixB;
|
||||
float4 texclamp;
|
||||
float2 texclampoff;
|
||||
R"( float4x4 u_proj;
|
||||
float4x4 u_proj_through;
|
||||
float4x4 u_view;
|
||||
float4x4 u_world;
|
||||
float4x4 u_tex;
|
||||
float4 u_uvscaleoffset;
|
||||
float4 u_depthRange;
|
||||
float3 u_fogcoef_stencilreplace;
|
||||
float4 u_matambientalpha;
|
||||
float3 u_fogcolor;
|
||||
float3 u_texenv;
|
||||
uint4 u_alphacolorref;
|
||||
uint4 u_alphacolormask;
|
||||
float3 u_blendFixA;
|
||||
float3 u_blendFixB;
|
||||
float4 u_texclamp;
|
||||
float2 u_texclampoff;
|
||||
)";
|
||||
|
||||
// 576 bytes. Can we get down to 512?
|
||||
|
@ -111,19 +112,20 @@ R"( vec4 globalAmbient;
|
|||
vec3 specular[4];
|
||||
)";
|
||||
|
||||
// HLSL code is shared so these names are changed to match those in DX9.
|
||||
static const char *cb_vs_lightsStr =
|
||||
R"( float4 globalAmbient;
|
||||
float3 matdiffuse;
|
||||
float4 matspecular;
|
||||
float3 matemissive;
|
||||
float3 pos[4];
|
||||
float3 dir[4];
|
||||
float3 att[4];
|
||||
float angle[4];
|
||||
float spotCoef[4];
|
||||
float3 ambient[4];
|
||||
float3 diffuse[4];
|
||||
float3 specular[4];
|
||||
float3 u_matdiffuse;
|
||||
float4 u_matspecular;
|
||||
float3 u_matemissive;
|
||||
float3 u_lightpos[4];
|
||||
float3 u_lightdir[4];
|
||||
float3 u_lightatt[4];
|
||||
float u_lightangle[4];
|
||||
float u_lightspotCoef[4];
|
||||
float3 u_ambient[4];
|
||||
float3 u_diffuse[4];
|
||||
float3 u_specular[4];
|
||||
)";
|
||||
|
||||
// With some cleverness, we could get away with uploading just half this when only the four first
|
||||
|
@ -137,8 +139,9 @@ static const char *ub_vs_bonesStr =
|
|||
R"( mat4 m[8];
|
||||
)";
|
||||
|
||||
// HLSL code is shared so these names are changed to match those in DX9.
|
||||
static const char *cb_vs_bonesStr =
|
||||
R"( matrix m[8];
|
||||
R"( float4x4 m[8];
|
||||
)";
|
||||
|
||||
void BaseUpdateUniforms(UB_VS_FS_Base *ub, uint64_t dirtyUniforms);
|
||||
|
|
|
@ -11,9 +11,10 @@ static std::vector<uint8_t> CompileShaderToBytecode(const char *code, size_t cod
|
|||
ID3DBlob *compiledCode = nullptr;
|
||||
ID3DBlob *errorMsgs = nullptr;
|
||||
HRESULT result = ptr_D3DCompile(code, codeSize, nullptr, nullptr, nullptr, "main", target, 0, 0, &compiledCode, &errorMsgs);
|
||||
std::string errors;
|
||||
if (errorMsgs) {
|
||||
std::string errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
|
||||
ELOG("%s: %s\n%s", SUCCEEDED(result) ? "warnings" : "errors", code, errors.c_str());
|
||||
errors = std::string((const char *)errorMsgs->GetBufferPointer(), errorMsgs->GetBufferSize());
|
||||
ELOG("%s: %s\n%s", SUCCEEDED(result) ? "warnings" : "errors", errors.c_str(), code);
|
||||
errorMsgs->Release();
|
||||
}
|
||||
if (compiledCode) {
|
||||
|
@ -22,6 +23,7 @@ static std::vector<uint8_t> CompileShaderToBytecode(const char *code, size_t cod
|
|||
compiledCode->Release();
|
||||
return compiled;
|
||||
}
|
||||
Crash();
|
||||
return std::vector<uint8_t>();
|
||||
}
|
||||
|
||||
|
@ -53,6 +55,7 @@ void StockObjectsD3D11::Create(ID3D11Device *device) {
|
|||
device->CreateBlendState(&blend_desc, &blendStateDisabledWithColorMask[i]);
|
||||
}
|
||||
D3D11_DEPTH_STENCIL_DESC depth_desc{};
|
||||
depth_desc.DepthEnable = FALSE;
|
||||
device->CreateDepthStencilState(&depth_desc, &depthStencilDisabled);
|
||||
depth_desc.StencilEnable = TRUE;
|
||||
depth_desc.StencilReadMask = 0xFF;
|
||||
|
|
|
@ -30,6 +30,7 @@ public:
|
|||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
device->CreateBuffer(&desc, nullptr, &buffer_);
|
||||
}
|
||||
PushBufferD3D11(PushBufferD3D11 &) = delete;
|
||||
~PushBufferD3D11() {
|
||||
buffer_->Release();
|
||||
}
|
||||
|
|
|
@ -101,8 +101,11 @@ ID3D11ShaderResourceView *DepalShaderCacheD3D11::GetClutTexture(GEPaletteFormat
|
|||
desc.Width = texturePixels;
|
||||
desc.Height = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.MipLevels = 1;
|
||||
desc.Format = dstFmt;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Usage = D3D11_USAGE_IMMUTABLE;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
|
||||
D3D11_SUBRESOURCE_DATA data{};
|
||||
data.pSysMem = rawClut;
|
||||
|
@ -114,7 +117,10 @@ ID3D11ShaderResourceView *DepalShaderCacheD3D11::GetClutTexture(GEPaletteFormat
|
|||
delete tex;
|
||||
return nullptr;
|
||||
}
|
||||
device_->CreateShaderResourceView(tex->texture, nullptr, &tex->view);
|
||||
hr = device_->CreateShaderResourceView(tex->texture, nullptr, &tex->view);
|
||||
if (FAILED(hr)) {
|
||||
// ...
|
||||
}
|
||||
tex->lastFrame = gpuStats.numFlips;
|
||||
texCache_[realClutID] = tex;
|
||||
return tex->view;
|
||||
|
|
|
@ -57,6 +57,10 @@ enum {
|
|||
#define VERTEXCACHE_DECIMATION_INTERVAL 17
|
||||
|
||||
enum { VAI_KILL_AGE = 120, VAI_UNRELIABLE_KILL_AGE = 240, VAI_UNRELIABLE_KILL_MAX = 4 };
|
||||
enum {
|
||||
VERTEX_PUSH_SIZE = 1024 * 1024 * 16,
|
||||
INDEX_PUSH_SIZE = 1024 * 1024 * 4,
|
||||
};
|
||||
|
||||
static const D3D11_INPUT_ELEMENT_DESC TransformedVertexElements[] = {
|
||||
{ "POSITION", 0, DXGI_FORMAT_R32G32B32A32_FLOAT, 0, 0, D3D11_INPUT_PER_VERTEX_DATA, 0 },
|
||||
|
@ -99,9 +103,16 @@ DrawEngineD3D11::DrawEngineD3D11(ID3D11Device *device, ID3D11DeviceContext *cont
|
|||
|
||||
tessDataTransfer = new TessellationDataTransferD3D11();
|
||||
transformedVertexDecl_ = nullptr;
|
||||
|
||||
// Vertex pushing buffers.
|
||||
pushVerts_ = new PushBufferD3D11(device, VERTEX_PUSH_SIZE, D3D11_BIND_VERTEX_BUFFER);
|
||||
pushInds_ = new PushBufferD3D11(device, INDEX_PUSH_SIZE, D3D11_BIND_INDEX_BUFFER);
|
||||
}
|
||||
|
||||
DrawEngineD3D11::~DrawEngineD3D11() {
|
||||
delete pushVerts_;
|
||||
delete pushInds_;
|
||||
|
||||
if (transformedVertexDecl_) {
|
||||
transformedVertexDecl_->Release();
|
||||
}
|
||||
|
@ -837,7 +848,8 @@ rotateVBO:
|
|||
ID3D11Buffer *pushVertData = pushVerts_->Buf();
|
||||
ID3D11Buffer *pushIndexData = pushInds_->Buf();
|
||||
UINT strides = sizeof(TransformedVertex);
|
||||
context_->IASetVertexBuffers(0, 1, &pushVertData, &strides, nullptr);
|
||||
UINT offsets = 0;
|
||||
context_->IASetVertexBuffers(0, 1, &pushVertData, &strides, &offsets);
|
||||
if (drawIndexed) {
|
||||
context_->IASetIndexBuffer(pushIndexData, DXGI_FORMAT_R16_UINT, 0);
|
||||
context_->DrawIndexed(numTrans, 0, 0);
|
||||
|
|
|
@ -173,6 +173,11 @@ void FramebufferManagerD3D11::MakePixelTexture(const u8 *srcPixels, GEBufferForm
|
|||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.Width = width;
|
||||
desc.Height = height;
|
||||
desc.MipLevels = 1;
|
||||
desc.ArraySize = 1;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Format = DXGI_FORMAT_R8G8B8A8_UNORM;
|
||||
desc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
|
||||
device_->CreateTexture2D(&desc, nullptr, &drawPixelsTex_);
|
||||
device_->CreateShaderResourceView(drawPixelsTex_, nullptr, &drawPixelsTexView_);
|
||||
drawPixelsTexW_ = width;
|
||||
|
|
|
@ -1107,6 +1107,7 @@ void TextureCacheD3D11::LoadTextureLevel(TexCacheEntry &entry, ReplacedTexture &
|
|||
desc.CPUAccessFlags = D3D11_CPU_ACCESS_WRITE;
|
||||
desc.Usage = D3D11_USAGE_DYNAMIC;
|
||||
desc.ArraySize = 1;
|
||||
desc.SampleDesc.Count = 1;
|
||||
desc.Width = tw;
|
||||
desc.Height = th;
|
||||
desc.MipLevels = levels;
|
||||
|
|
|
@ -105,7 +105,7 @@ bool GenerateFragmentShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage
|
|||
WRITE(p, "float3 u_fogcolor : register(c%i);\n", CONST_PS_FOGCOLOR);
|
||||
}
|
||||
} else {
|
||||
WRITE(p, "cbuffer base : register(b0) %s;\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", cb_baseStr);
|
||||
}
|
||||
|
||||
if (enableAlphaTest) {
|
||||
|
|
|
@ -104,9 +104,8 @@ void GenerateVertexShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage l
|
|||
numBoneWeights = 1 + id.Bits(VS_BIT_BONES, 3);
|
||||
}
|
||||
|
||||
WRITE(p, "#pragma warning( disable : 3571 )\n");
|
||||
|
||||
if (lang == HLSL_DX9) {
|
||||
WRITE(p, "#pragma warning( disable : 3571 )\n");
|
||||
if (isModeThrough) {
|
||||
WRITE(p, "float4x4 u_proj_through : register(c%i);\n", CONST_VS_PROJ_THROUGH);
|
||||
} else {
|
||||
|
@ -177,9 +176,9 @@ void GenerateVertexShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage l
|
|||
WRITE(p, "float4 u_depthRange : register(c%i);\n", CONST_VS_DEPTHRANGE);
|
||||
}
|
||||
} else {
|
||||
WRITE(p, "cbuffer base : register(b0) %s;\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) %s;\n", cb_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) %s;\n", cb_vs_bonesStr);
|
||||
WRITE(p, "cbuffer base : register(b0) {\n%s};\n", cb_baseStr);
|
||||
WRITE(p, "cbuffer lights: register(b1) {\n%s};\n", cb_vs_lightsStr);
|
||||
WRITE(p, "cbuffer bones : register(b2) {\n%s};\n", cb_vs_bonesStr);
|
||||
}
|
||||
|
||||
// And the "varyings".
|
||||
|
|
Loading…
Add table
Reference in a new issue