Merge pull request #11684 from hrydgard/more-gpudriver-test

GPU driver test: This should finally repro one of the Adreno bugs
This commit is contained in:
Henrik Rydgård authored and GitHub committed 2018-12-20 11:15:40 +01:00
commit 7e14789e79
3 files changed
+118 -54

No files matched your search

+107 -52
View File
@@ -47,6 +47,11 @@ GPUDriverTestScreen::GPUDriverTestScreen() {
GPUDriverTestScreen::~GPUDriverTestScreen() {
if (discardWriteDepthStencil_)
discardWriteDepthStencil_->Release();
if (discardWriteDepth_)
discardWriteDepth_->Release();
if (discardWriteStencil_)
discardWriteStencil_->Release();
if (drawTestStencilEqualDepthAlways_)
drawTestStencilEqualDepthAlways_->Release();
if (drawTestStencilNotEqualDepthAlways_)
@@ -55,12 +60,17 @@ GPUDriverTestScreen::~GPUDriverTestScreen() {
drawTestStencilEqual_->Release();
if (drawTestStencilNotEqual_)
drawTestStencilNotEqual_->Release();
if (drawTestStencilAlwaysDepthLessEqual_)
drawTestStencilAlwaysDepthLessEqual_->Release();
if (drawTestStencilAlwaysDepthGreater_)
drawTestStencilAlwaysDepthGreater_->Release();
if (drawTestDepthLessEqual_)
drawTestDepthLessEqual_->Release();
if (drawTestDepthGreater_)
drawTestDepthGreater_->Release();
if (discard_)
discard_->Release();
if (discardFragShader_)
discardFragShader_->Release();
if (samplerNearest_)
samplerNearest_->Release();
}
@@ -91,7 +101,7 @@ void GPUDriverTestScreen::DiscardTest() {
// Create the special shader module.
discard_ = CreateShader(draw, Draw::ShaderStage::FRAGMENT, fsDiscard);
discardFragShader_ = CreateShader(draw, Draw::ShaderStage::FRAGMENT, fsDiscard);
InputLayout *inputLayout = ui_draw2d.CreateInputLayout(draw);
BlendState *blendOff = draw->CreateBlendState({ false, 0xF });
@@ -111,32 +121,52 @@ void GPUDriverTestScreen::DiscardTest() {
dsDesc.back = dsDesc.front;
DepthStencilState *depthStencilWrite = draw->CreateDepthStencilState(dsDesc);
// Write only depth.
dsDesc.stencilEnabled = false;
DepthStencilState *depthWrite = draw->CreateDepthStencilState(dsDesc);
// Write only stencil.
dsDesc.stencilEnabled = true;
dsDesc.depthTestEnabled = false;
DepthStencilState *stencilWrite = draw->CreateDepthStencilState(dsDesc);
// Now for the shaders that read depth and/or stencil.
dsDesc.depthTestEnabled = true;
dsDesc.stencilEnabled = true;
dsDesc.depthCompare = Comparison::ALWAYS;
dsDesc.front.compareOp = Comparison::EQUAL;
dsDesc.back = dsDesc.front;
DepthStencilState *stencilTestEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);
DepthStencilState *stencilEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);
dsDesc.depthTestEnabled = false;
dsDesc.front.compareOp = Comparison::EQUAL;
dsDesc.back = dsDesc.front;
DepthStencilState *stencilTestEqual = draw->CreateDepthStencilState(dsDesc);
DepthStencilState *stencilEqual = draw->CreateDepthStencilState(dsDesc);
dsDesc.depthTestEnabled = true;
dsDesc.depthCompare = Comparison::ALWAYS;
dsDesc.front.compareOp = Comparison::NOT_EQUAL;
dsDesc.back = dsDesc.front;
DepthStencilState *stencilTestNotEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);
DepthStencilState *stenciNotEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);
dsDesc.depthTestEnabled = false;
dsDesc.front.compareOp = Comparison::NOT_EQUAL;
dsDesc.back = dsDesc.front;
DepthStencilState *stencilTestNotEqual = draw->CreateDepthStencilState(dsDesc);
DepthStencilState *stencilNotEqual = draw->CreateDepthStencilState(dsDesc);
dsDesc.stencilEnabled = true;
dsDesc.depthTestEnabled = true;
dsDesc.depthCompare = Comparison::LESS_EQUAL;
dsDesc.front.compareOp = Comparison::ALWAYS;
dsDesc.back = dsDesc.front;
dsDesc.depthCompare = Comparison::LESS_EQUAL;
DepthStencilState *stencilAlwaysDepthTestLessEqual = draw->CreateDepthStencilState(dsDesc);
dsDesc.depthCompare = Comparison::GREATER;
DepthStencilState *stencilAlwaysDepthTestGreater = draw->CreateDepthStencilState(dsDesc);
dsDesc.stencilEnabled = false;
dsDesc.depthTestEnabled = true;
dsDesc.depthCompare = Comparison::LESS_EQUAL;
DepthStencilState *depthTestLessEqual = draw->CreateDepthStencilState(dsDesc);
dsDesc.depthCompare = Comparison::GREATER;
DepthStencilState *depthTestGreater = draw->CreateDepthStencilState(dsDesc);
@@ -145,27 +175,37 @@ void GPUDriverTestScreen::DiscardTest() {
PipelineDesc discardDesc{
Primitive::TRIANGLE_LIST,
{ draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D), discard_ },
{ draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D), discardFragShader_ },
inputLayout, depthStencilWrite, blendOff, rasterNoCull, &vsColBufDesc,
};
discardWriteDepthStencil_ = draw->CreateGraphicsPipeline(discardDesc);
discardDesc.depthStencil = depthWrite;
discardWriteDepth_ = draw->CreateGraphicsPipeline(discardDesc);
discardDesc.depthStencil = stencilWrite;
discardWriteStencil_ = draw->CreateGraphicsPipeline(discardDesc);
PipelineDesc testDesc{
Primitive::TRIANGLE_LIST,
{ draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D), draw->GetFshaderPreset(FS_TEXTURE_COLOR_2D) },
inputLayout, stencilTestEqual, blendOff, rasterNoCull, &vsColBufDesc,
inputLayout, stencilEqual, blendOff, rasterNoCull, &vsColBufDesc,
};
drawTestStencilEqual_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = stencilTestEqualDepthAlways;
testDesc.depthStencil = stencilEqualDepthAlways;
drawTestStencilEqualDepthAlways_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = stencilTestNotEqual;
testDesc.depthStencil = stencilNotEqual;
drawTestStencilNotEqual_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = stencilTestNotEqualDepthAlways;
testDesc.depthStencil = stenciNotEqualDepthAlways;
drawTestStencilNotEqualDepthAlways_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = stencilAlwaysDepthTestGreater;
drawTestStencilAlwaysDepthGreater_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = stencilAlwaysDepthTestLessEqual;
drawTestStencilAlwaysDepthLessEqual_ = draw->CreateGraphicsPipeline(testDesc);
testDesc.depthStencil = depthTestGreater;
drawTestDepthGreater_ = draw->CreateGraphicsPipeline(testDesc);
@@ -175,10 +215,12 @@ void GPUDriverTestScreen::DiscardTest() {
inputLayout->Release();
blendOff->Release();
depthStencilWrite->Release();
stencilTestEqual->Release();
stencilTestNotEqual->Release();
stencilTestEqualDepthAlways->Release();
stencilTestNotEqualDepthAlways->Release();
stencilEqual->Release();
stencilNotEqual->Release();
stencilEqualDepthAlways->Release();
stenciNotEqualDepthAlways->Release();
stencilAlwaysDepthTestLessEqual->Release();
stencilAlwaysDepthTestGreater->Release();
depthTestLessEqual->Release();
depthTestGreater->Release();
rasterNoCull->Release();
@@ -191,12 +233,21 @@ void GPUDriverTestScreen::DiscardTest() {
Draw::DrawContext *draw = dc.GetDrawContext();
const Bounds &bounds = dc.GetBounds();
const char *testNames[] = { "Stencil", "Stencil+DepthA", "StencilA+Depth" };
Pipeline *testPipeline1[] = { drawTestStencilEqual_, drawTestStencilEqualDepthAlways_, drawTestDepthLessEqual_ };
Pipeline *testPipeline2[] = { drawTestStencilNotEqual_, drawTestStencilNotEqualDepthAlways_, drawTestDepthGreater_ };
static const char * const writeModeNames[] = { "Stencil+Depth", "Stencil", "Depth" };
Pipeline *writePipelines[] = { discardWriteDepthStencil_, discardWriteStencil_, discardWriteDepth_ };
const int numWriteModes = ARRAY_SIZE(writeModeNames);
static const char * const testNames[] = { "Stenc", "Stenc+DepthA", "Depth", "StencA+Depth" };
Pipeline *testPipeline1[] = { drawTestStencilEqual_, drawTestStencilEqualDepthAlways_, drawTestDepthLessEqual_, drawTestStencilAlwaysDepthLessEqual_ };
Pipeline *testPipeline2[] = { drawTestStencilNotEqual_, drawTestStencilNotEqualDepthAlways_, drawTestDepthGreater_, drawTestStencilAlwaysDepthGreater_ };
const int numTests = ARRAY_SIZE(testNames);
static const bool validCombinations[numWriteModes][numTests] = {
{true, true, true, true},
{true, true, false, false},
{false, false, true, true},
};
uint32_t textColorOK = 0xFF30FF30;
uint32_t textColorBAD = 0xFF3030FF;
uint32_t bgColorOK = 0xFF106010;
@@ -212,6 +263,7 @@ void GPUDriverTestScreen::DiscardTest() {
// If everything is OK, both the background and the text should be OK.
dc.Begin();
dc.SetFontScale(1.0f, 1.0f);
std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME);
std::string vendor = screenManager()->getDrawContext()->GetInfoString(InfoField::VENDORSTRING);
std::string driver = screenManager()->getDrawContext()->GetInfoString(InfoField::DRIVER);
@@ -220,49 +272,52 @@ void GPUDriverTestScreen::DiscardTest() {
dc.DrawText(driver.c_str(), bounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);
dc.Flush();
float testW = 220.f;
float testW = 170.f;
float padding = 20.0f;
UI::Style style = dc.theme->itemStyle;
float y = 150;
float x = (dc.GetBounds().w - (float)numTests * testW - (float)(numTests - 1) * padding) / 2.0f;
for (int i = 0; i < numTests; i++) {
for (int j = 0; j < numWriteModes; j++, y += 120.f + padding) {
float x = (dc.GetBounds().w - (float)numTests * testW - (float)(numTests - 1) * padding) / 2.0f;
dc.Begin();
dc.SetFontScale(1.0f, 1.0f);
Bounds bounds = { x, y + 40, testW, 70 };
dc.DrawText(testNames[i], bounds.x, y, style.fgColor, FLAG_DYNAMIC_ASCII);
dc.DrawText(writeModeNames[j], padding, y + 40, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);
dc.Flush();
for (int i = 0; i < numTests; i++, x += testW + padding) {
if (!validCombinations[j][i])
continue;
dc.Begin();
Bounds bounds = { x, y + 40, testW, 70 };
dc.DrawText(testNames[i], bounds.x, y, style.fgColor, FLAG_DYNAMIC_ASCII);
dc.Flush();
dc.BeginPipeline(discardWriteDepthStencil_, samplerNearest_);
// Draw the rectangle with stencil value 0, depth 0.1f and the text with stencil 0xFF, depth 0.9. Then leave 0xFF as the stencil value and draw the rectangles at depth 0.5.
draw->SetStencilRef(0x0);
dc.SetCurZ(0.1f);
dc.FillRect(UI::Drawable(bgColorBAD), bounds);
// test bounds
dc.Flush();
dc.BeginPipeline(writePipelines[j], samplerNearest_);
// Draw the rectangle with stencil value 0, depth 0.1f and the text with stencil 0xFF, depth 0.9. Then leave 0xFF as the stencil value and draw the rectangles at depth 0.5.
draw->SetStencilRef(0x0);
dc.SetCurZ(0.1f);
dc.FillRect(UI::Drawable(bgColorBAD), bounds);
// test bounds
dc.Flush();
draw->SetStencilRef(0xff);
dc.SetCurZ(0.9f);
dc.DrawTextRect("TEST OK", bounds, textColorBAD, ALIGN_HCENTER | ALIGN_VCENTER | FLAG_DYNAMIC_ASCII);
dc.Flush();
draw->SetStencilRef(0xff);
dc.SetCurZ(0.9f);
dc.DrawTextRect("TEST OK", bounds, textColorBAD, ALIGN_HCENTER | ALIGN_VCENTER | FLAG_DYNAMIC_ASCII);
dc.Flush();
// Draw rectangle that should result in the text
dc.BeginPipeline(testPipeline1[i], samplerNearest_);
draw->SetStencilRef(0xff);
dc.SetCurZ(0.5f);
dc.FillRect(UI::Drawable(textColorOK), bounds);
dc.Flush();
// Draw rectangle that should result in the text
dc.BeginPipeline(testPipeline1[i], samplerNearest_);
draw->SetStencilRef(0xff);
dc.SetCurZ(0.5f);
dc.FillRect(UI::Drawable(textColorOK), bounds);
dc.Flush();
// Draw rectangle that should result in the bg
dc.BeginPipeline(testPipeline2[i], samplerNearest_);
draw->SetStencilRef(0xff);
dc.SetCurZ(0.5f);
dc.FillRect(UI::Drawable(bgColorOK), bounds);
dc.Flush();
x += testW + padding;
// Draw rectangle that should result in the bg
dc.BeginPipeline(testPipeline2[i], samplerNearest_);
draw->SetStencilRef(0xff);
dc.SetCurZ(0.5f);
dc.FillRect(UI::Drawable(bgColorOK), bounds);
dc.Flush();
}
}
dc.SetFontScale(1.0f, 1.0f);
dc.Flush();
}
+10 -1
View File
@@ -23,14 +23,23 @@ public:
private:
void DiscardTest();
Draw::ShaderModule *discard_ = nullptr;
Draw::ShaderModule *discardFragShader_ = nullptr;
Draw::Pipeline *discardWriteDepthStencil_ = nullptr;
Draw::Pipeline *discardWriteDepth_ = nullptr;
Draw::Pipeline *discardWriteStencil_ = nullptr;
// Stencil test, with and without DepthAlways
Draw::Pipeline *drawTestStencilEqual_ = nullptr;
Draw::Pipeline *drawTestStencilNotEqual_ = nullptr;
Draw::Pipeline *drawTestStencilEqualDepthAlways_ = nullptr;
Draw::Pipeline *drawTestStencilNotEqualDepthAlways_ = nullptr;
// Depth tests with and without StencilAlways
Draw::Pipeline *drawTestStencilAlwaysDepthLessEqual_ = nullptr;
Draw::Pipeline *drawTestStencilAlwaysDepthGreater_ = nullptr;
Draw::Pipeline *drawTestDepthLessEqual_ = nullptr;
Draw::Pipeline *drawTestDepthGreater_ = nullptr;
Draw::SamplerState *samplerNearest_ = nullptr;
UI::TabHolder *tabHolder_ = nullptr;
};
+1 -1
View File
@@ -186,7 +186,7 @@ public:
bool depthTestEnabled;
bool depthWriteEnabled;
GLuint depthComp;
// TODO: Two-sided
// TODO: Two-sided. Although in practice, do we care?
bool stencilEnabled;
GLuint stencilFail;
GLuint stencilZFail;