Further D3D11 fixes

This commit is contained in:
Henrik Rydgård 2017-02-12 16:14:14 +01:00
parent 05bdf8abbf
commit 4f2fb10347
5 changed files with 21 additions and 17 deletions

View file

@ -69,7 +69,7 @@ R"( float4x4 u_proj;
float4x4 u_tex;
float4 u_uvscaleoffset;
float4 u_depthRange;
float3 u_fogcoef;
float3 u_fogcoef_stencilreplace;
float4 u_matambientalpha;
float3 u_fogcolor;
float3 u_texenv;

View file

@ -502,7 +502,7 @@ void SoftwareTransform(
const u16 *indsIn = (const u16 *)inds;
u16 *newInds = inds + vertexCount;
u16 *indsOut = newInds;
maxIndex = 4 * vertexCount;
maxIndex = 4 * (vertexCount / 2);
for (int i = 0; i < vertexCount; i += 2) {
const TransformedVertex &transVtxTL = transformed[indsIn[i + 0]];
const TransformedVertex &transVtxBR = transformed[indsIn[i + 1]];

View file

@ -40,13 +40,13 @@
#include "GPU/D3D11/ShaderManagerD3D11.h"
#include "GPU/D3D11/GPU_D3D11.h"
const D3D11_PRIMITIVE_TOPOLOGY glprim[8] = {
const D3D11_PRIMITIVE_TOPOLOGY d3d11prim[8] = {
D3D11_PRIMITIVE_TOPOLOGY_POINTLIST,
D3D11_PRIMITIVE_TOPOLOGY_LINELIST,
D3D11_PRIMITIVE_TOPOLOGY_LINESTRIP,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST,
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLESTRIP,
D3D11_PRIMITIVE_TOPOLOGY_UNDEFINED, // Fans not supported
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, // Fans not supported
D3D11_PRIMITIVE_TOPOLOGY_TRIANGLELIST, // Need expansion - though we could do it with geom shaders in most cases
};
@ -104,7 +104,9 @@ DrawEngineD3D11::DrawEngineD3D11(Draw::DrawContext *draw, ID3D11Device *device,
tessDataTransfer = new TessellationDataTransferD3D11();
// Vertex pushing buffers.
// Vertex pushing buffers. For uniforms we use short DISCARD buffers, but we could use
// this kind of buffer there as well with D3D11.1. We might be able to use the same buffer
// for both vertices and indices, and possibly all three data types.
pushVerts_ = new PushBufferD3D11(device, VERTEX_PUSH_SIZE, D3D11_BIND_VERTEX_BUFFER);
pushInds_ = new PushBufferD3D11(device, INDEX_PUSH_SIZE, D3D11_BIND_INDEX_BUFFER);
}
@ -113,10 +115,8 @@ DrawEngineD3D11::~DrawEngineD3D11() {
delete pushVerts_;
delete pushInds_;
for (auto decl = inputLayoutMap_.begin(); decl != inputLayoutMap_.end(); ++decl) {
if (decl->second) {
decl->second->Release();
}
for (auto &decl : inputLayoutMap_) {
decl.second->Release();
}
for (auto &depth : depthStencilCache_) {
depth.second->Release();
@ -559,12 +559,10 @@ void DrawEngineD3D11::BeginFrame() {
}
VertexArrayInfoD3D11::~VertexArrayInfoD3D11() {
if (vbo) {
if (vbo)
vbo->Release();
}
if (ebo) {
if (ebo)
ebo->Release();
}
}
static uint32_t SwapRB(uint32_t c) {
@ -775,7 +773,7 @@ rotateVBO:
context_->IASetInputLayout(inputLayout);
UINT stride = dec_->GetDecVtxFmt().stride;
context_->IASetPrimitiveTopology(glprim[prim]);
context_->IASetPrimitiveTopology(d3d11prim[prim]);
if (!vb_) {
// Push!
UINT vOffset;
@ -869,6 +867,7 @@ rotateVBO:
layout = iter->second;
}
context_->IASetInputLayout(layout);
context_->IASetPrimitiveTopology(d3d11prim[prim]);
UINT stride = sizeof(TransformedVertex);
UINT vOffset = 0;

View file

@ -341,7 +341,7 @@ bool GenerateFragmentShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage
if (stencilToAlpha != REPLACE_ALPHA_NO) {
switch (replaceAlphaWithStencilType) {
case STENCIL_VALUE_UNIFORM:
replacedAlpha = "u_stencilReplaceValue";
replacedAlpha = lang == HLSL_D3D11 ? "u_fogcoef_stencilreplace.z" : "u_stencilReplaceValue";
break;
case STENCIL_VALUE_ZERO:

View file

@ -604,8 +604,13 @@ void GenerateVertexShaderHLSL(const ShaderID &id, char *buffer, ShaderLanguage l
}
// Compute fogdepth
if (enableFog)
WRITE(p, " Out.v_fogdepth.x = (viewPos.z + u_fogcoef.x) * u_fogcoef.y;\n");
if (enableFog) {
if (lang == HLSL_D3D11) {
WRITE(p, " Out.v_fogdepth.x = (viewPos.z + u_fogcoef_stencilreplace.x) * u_fogcoef_stencilreplace.y;\n");
} else {
WRITE(p, " Out.v_fogdepth.x = (viewPos.z + u_fogcoef.x) * u_fogcoef.y;\n");
}
}
}
WRITE(p, " return Out;\n");