CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/UI/GPUDriverTestScreen.cpp
Views: 1401
#include "GPUDriverTestScreen.h"1#include "Common/Data/Text/I18n.h"2#include "Common/UI/UI.h"3#include "Common/UI/View.h"4#include "Common/GPU/Shader.h"5#include "Common/GPU/ShaderWriter.h"67const uint32_t textColorOK = 0xFF30FF30;8const uint32_t textColorBAD = 0xFF3030FF;9const uint32_t bgColorOK = 0xFF106010;10const uint32_t bgColorBAD = 0xFF101060;1112// TODO: One day, port these to use ShaderWriter.1314static const std::vector<Draw::ShaderSource> fsDiscard = {15{ShaderLanguage::GLSL_1xx,16R"(17#ifdef GL_ES18precision lowp float;19#endif20#if __VERSION__ >= 13021#define varying in22#define gl_FragColor fragColor023out vec4 fragColor0;24#endif25varying vec4 oColor0;26varying vec2 oTexCoord0;27uniform sampler2D Sampler0;28void main() {29#if __VERSION__ >= 13030vec4 color = texture(Sampler0, oTexCoord0) * oColor0;31#else32vec4 color = texture2D(Sampler0, oTexCoord0) * oColor0;33#endif34if (color.a <= 0.0)35discard;36gl_FragColor = color;37})"38},39{ShaderLanguage::GLSL_VULKAN,40R"(#version 45041#extension GL_ARB_separate_shader_objects : enable42#extension GL_ARB_shading_language_420pack : enable43layout(location = 0) in vec4 oColor0;44layout(location = 1) in vec2 oTexCoord0;45layout(location = 0) out vec4 fragColor0;46layout(set = 0, binding = 1) uniform sampler2D Sampler0;47void main() {48vec4 color = texture(Sampler0, oTexCoord0) * oColor0;49if (color.a <= 0.0)50discard;51fragColor0 = color;52})"53},54};5556static const std::vector<Draw::ShaderSource> fsAdrenoLogicTest = {57{ShaderLanguage::GLSL_1xx,58R"(59#ifdef GL_ES60precision lowp float;61#endif62#if __VERSION__ >= 13063#define varying in64#define gl_FragColor fragColor065out vec4 fragColor0;66#endif67varying vec4 oColor0;68varying vec2 oTexCoord0;69uniform sampler2D Sampler0;70void main() {71#if __VERSION__ >= 13072vec4 color = (texture(Sampler0, oTexCoord0) * oColor0).aaaa;73#else74vec4 color = (texture2D(Sampler0, oTexCoord0) * oColor0).aaaa;75#endif76color *= 2.0;77if (color.r < 0.002 && color.g < 0.002 && color.b < 0.002) discard;78gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);79})"80},81{ShaderLanguage::GLSL_VULKAN,82R"(#version 45083#extension GL_ARB_separate_shader_objects : enable84#extension GL_ARB_shading_language_420pack : enable85layout(location = 0) in vec4 oColor0;86layout(location = 1) in highp vec2 oTexCoord0;87layout(location = 0) out vec4 fragColor0;88layout(set = 0, binding = 1) uniform sampler2D Sampler0;89void main() {90vec4 v = texture(Sampler0, oTexCoord0).aaaa * oColor0;91if (v.r < 0.2 && v.g < 0.2 && v.b < 0.2) discard;92fragColor0 = vec4(0.0, 1.0, 0.0, 1.0);93})"94},95};9697static const std::vector<Draw::ShaderSource> vsAdrenoLogicTest = {98{ GLSL_1xx,99"#if __VERSION__ >= 130\n"100"#define attribute in\n"101"#define varying out\n"102"#endif\n"103"attribute vec3 Position;\n"104"attribute vec4 Color0;\n"105"attribute vec2 TexCoord0;\n"106"varying vec4 oColor0;\n"107"varying vec2 oTexCoord0;\n"108"uniform mat4 WorldViewProj;\n"109"void main() {\n"110" gl_Position = WorldViewProj * vec4(Position, 1.0);\n"111" oColor0 = Color0;\n"112" oTexCoord0 = TexCoord0;\n"113"}\n"114},115{ ShaderLanguage::GLSL_VULKAN,116"#version 450\n"117"#extension GL_ARB_separate_shader_objects : enable\n"118"#extension GL_ARB_shading_language_420pack : enable\n"119"layout (std140, set = 0, binding = 0) uniform bufferVals {\n"120" mat4 WorldViewProj;\n"121"} myBufferVals;\n"122"layout (location = 0) in vec4 pos;\n"123"layout (location = 1) in vec4 inColor;\n"124"layout (location = 3) in vec2 inTexCoord;\n"125"layout (location = 0) out vec4 outColor;\n"126"layout (location = 1) out highp vec2 outTexCoord;\n"127"out gl_PerVertex { vec4 gl_Position; };\n"128"void main() {\n"129" outColor = inColor;\n"130" outTexCoord = inTexCoord;\n"131" gl_Position = myBufferVals.WorldViewProj * pos;\n"132"}\n"133}134};135136static const std::vector<Draw::ShaderSource> fsFlat = {137{ShaderLanguage::GLSL_3xx,138"#ifdef GL_ES\n"139"precision lowp float;\n"140"precision highp int;\n"141"#endif\n"142"uniform sampler2D Sampler0;\n"143"flat in lowp vec4 oColor0;\n"144"in mediump vec3 oTexCoord0;\n"145"out vec4 fragColor0;\n"146"void main() {\n"147" vec4 t = texture(Sampler0, oTexCoord0.xy);\n"148" vec4 p = oColor0;\n"149" vec4 v = p * t;\n"150" fragColor0 = v;\n"151"}\n"152},153{ShaderLanguage::GLSL_1xx,154"#ifdef GL_ES\n"155"precision lowp float;\n"156"#endif\n"157"#if __VERSION__ >= 130\n"158"#define varying in\n"159"#define texture2D texture\n"160"#define gl_FragColor fragColor0\n"161"out vec4 fragColor0;\n"162"#endif\n"163"varying vec4 oColor0;\n"164"varying vec2 oTexCoord0;\n"165"uniform sampler2D Sampler0;\n"166"void main() { gl_FragColor = texture2D(Sampler0, oTexCoord0) * oColor0; }\n"167},168{ShaderLanguage::GLSL_VULKAN,169"#version 450\n"170"#extension GL_ARB_separate_shader_objects : enable\n"171"#extension GL_ARB_shading_language_420pack : enable\n"172"layout(location = 0) flat in lowp vec4 oColor0;\n"173"layout(location = 1) in highp vec2 oTexCoord0;\n"174"layout(location = 0) out vec4 fragColor0;\n"175"layout(set = 0, binding = 1) uniform sampler2D Sampler0;\n"176"void main() { fragColor0 = texture(Sampler0, oTexCoord0) * oColor0; }\n"177}178};179180static const std::vector<Draw::ShaderSource> vsFlat = {181{ GLSL_3xx,182"in vec3 Position;\n"183"in vec2 TexCoord0;\n"184"in lowp vec4 Color0;\n"185"uniform mat4 WorldViewProj;\n"186"flat out lowp vec4 oColor0;\n"187"out mediump vec3 oTexCoord0;\n"188"void main() {\n"189" oTexCoord0 = vec3(TexCoord0, 1.0);\n"190" oColor0 = Color0;\n"191" vec4 outPos = WorldViewProj * vec4(Position, 1.0);\n"192" gl_Position = outPos;\n"193"}\n"194},195{ GLSL_1xx, // Doesn't actually repro the problem since flat support isn't guaranteed196"#if __VERSION__ >= 130\n"197"#define attribute in\n"198"#define varying out\n"199"#endif\n"200"attribute vec3 Position;\n"201"attribute vec4 Color0;\n"202"attribute vec2 TexCoord0;\n"203"varying vec4 oColor0;\n"204"varying vec2 oTexCoord0;\n"205"uniform mat4 WorldViewProj;\n"206"void main() {\n"207" gl_Position = WorldViewProj * vec4(Position, 1.0);\n"208" oColor0 = Color0;\n"209" oTexCoord0 = TexCoord0;\n"210"}\n"211},212{ ShaderLanguage::GLSL_VULKAN,213"#version 450\n"214"#extension GL_ARB_separate_shader_objects : enable\n"215"#extension GL_ARB_shading_language_420pack : enable\n"216"layout (std140, set = 0, binding = 0) uniform bufferVals {\n"217" mat4 WorldViewProj;\n"218"} myBufferVals;\n"219"layout (location = 0) in vec4 pos;\n"220"layout (location = 1) in vec4 inColor;\n"221"layout (location = 3) in vec2 inTexCoord;\n"222"layout (location = 0) flat out lowp vec4 outColor;\n"223"layout (location = 1) out highp vec2 outTexCoord;\n"224"out gl_PerVertex { vec4 gl_Position; };\n"225"void main() {\n"226" outColor = inColor;\n"227" outTexCoord = inTexCoord;\n"228" gl_Position = myBufferVals.WorldViewProj * pos;\n"229"}\n"230}231};232233static_assert(Draw::SEM_TEXCOORD0 == 3, "Semantic shader hardcoded in glsl above.");234235GPUDriverTestScreen::GPUDriverTestScreen() {236using namespace Draw;237}238239GPUDriverTestScreen::~GPUDriverTestScreen() {240if (discardWriteDepthStencil_)241discardWriteDepthStencil_->Release();242if (discardWriteDepth_)243discardWriteDepth_->Release();244if (discardWriteStencil_)245discardWriteStencil_->Release();246247if (drawTestStencilEqualDepthAlways_)248drawTestStencilEqualDepthAlways_->Release();249if (drawTestStencilNotEqualDepthAlways_)250drawTestStencilNotEqualDepthAlways_->Release();251if (drawTestStencilEqual_)252drawTestStencilEqual_->Release();253if (drawTestStencilNotEqual_)254drawTestStencilNotEqual_->Release();255if (drawTestStencilAlwaysDepthLessEqual_)256drawTestStencilAlwaysDepthLessEqual_->Release();257if (drawTestStencilAlwaysDepthGreater_)258drawTestStencilAlwaysDepthGreater_->Release();259if (drawTestDepthLessEqual_)260drawTestDepthLessEqual_->Release();261if (drawTestDepthGreater_)262drawTestDepthGreater_->Release();263264if (discardFragShader_)265discardFragShader_->Release();266267// Shader test268if (adrenoLogicDiscardPipeline_)269adrenoLogicDiscardPipeline_->Release();270if (flatShadingPipeline_)271flatShadingPipeline_->Release();272273if (adrenoLogicDiscardFragShader_)274adrenoLogicDiscardFragShader_->Release();275if (adrenoLogicDiscardVertShader_)276adrenoLogicDiscardVertShader_->Release();277if (flatFragShader_)278flatFragShader_->Release();279if (flatVertShader_)280flatVertShader_->Release();281282if (samplerNearest_)283samplerNearest_->Release();284}285286void GPUDriverTestScreen::CreateViews() {287using namespace Draw;288289if (!samplerNearest_) {290DrawContext *draw = screenManager()->getDrawContext();291SamplerStateDesc nearestDesc{};292samplerNearest_ = draw->CreateSamplerState(nearestDesc);293}294295// Don't bother with views for now.296using namespace UI;297auto di = GetI18NCategory(I18NCat::DIALOG);298auto cr = GetI18NCategory(I18NCat::PSPCREDITS);299300AnchorLayout *anchor = new AnchorLayout();301root_ = anchor;302303tabHolder_ = new TabHolder(ORIENT_HORIZONTAL, 30.0f, new AnchorLayoutParams(FILL_PARENT, FILL_PARENT, false));304anchor->Add(tabHolder_);305tabHolder_->AddTab("Discard", new LinearLayout(ORIENT_VERTICAL));306tabHolder_->AddTab("Shader", new LinearLayout(ORIENT_VERTICAL));307308Choice *back = new Choice(di->T("Back"), "", false, new AnchorLayoutParams(100, WRAP_CONTENT, 10, NONE, NONE, 10));309back->OnClick.Handle<UIScreen>(this, &UIScreen::OnBack);310anchor->Add(back);311}312313void GPUDriverTestScreen::DiscardTest(UIContext &dc) {314using namespace UI;315using namespace Draw;316if (!discardWriteDepthStencil_) {317DrawContext *draw = screenManager()->getDrawContext();318319// Create the special shader module.320321discardFragShader_ = CreateShader(draw, ShaderStage::Fragment, fsDiscard);322323InputLayout *inputLayout = ui_draw2d.CreateInputLayout(draw);324BlendState *blendOff = draw->CreateBlendState({ false, 0xF });325BlendState *blendOffNoColor = draw->CreateBlendState({ false, 0x8 });326327// Write depth, write stencil.328DepthStencilStateDesc dsDesc{};329dsDesc.depthTestEnabled = true;330dsDesc.depthWriteEnabled = true;331dsDesc.depthCompare = Comparison::ALWAYS;332dsDesc.stencilEnabled = true;333dsDesc.stencil.compareOp = Comparison::ALWAYS;334dsDesc.stencil.passOp = StencilOp::REPLACE;335dsDesc.stencil.failOp = StencilOp::REPLACE; // These two shouldn't matter, because the test that fails is discard, not stencil.336dsDesc.stencil.depthFailOp = StencilOp::REPLACE;337DepthStencilState *depthStencilWrite = draw->CreateDepthStencilState(dsDesc);338339// Write only depth.340dsDesc.stencilEnabled = false;341DepthStencilState *depthWrite = draw->CreateDepthStencilState(dsDesc);342343// Write only stencil.344dsDesc.stencilEnabled = true;345dsDesc.depthTestEnabled = false;346dsDesc.depthWriteEnabled = false; // Just in case the driver is crazy. when test is enabled, though, this should be ignored.347DepthStencilState *stencilWrite = draw->CreateDepthStencilState(dsDesc);348349// Now for the shaders that read depth and/or stencil.350351dsDesc.depthTestEnabled = true;352dsDesc.stencilEnabled = true;353dsDesc.depthCompare = Comparison::ALWAYS;354dsDesc.stencil.compareOp = Comparison::EQUAL;355dsDesc.stencil.failOp = StencilOp::KEEP;356dsDesc.stencil.depthFailOp = StencilOp::KEEP;357DepthStencilState *stencilEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);358359dsDesc.depthTestEnabled = false;360dsDesc.stencil.compareOp = Comparison::EQUAL;361DepthStencilState *stencilEqual = draw->CreateDepthStencilState(dsDesc);362363dsDesc.depthTestEnabled = true;364dsDesc.depthCompare = Comparison::ALWAYS;365dsDesc.stencil.compareOp = Comparison::NOT_EQUAL;366DepthStencilState *stenciNotEqualDepthAlways = draw->CreateDepthStencilState(dsDesc);367368dsDesc.depthTestEnabled = false;369dsDesc.stencil.compareOp = Comparison::NOT_EQUAL;370DepthStencilState *stencilNotEqual = draw->CreateDepthStencilState(dsDesc);371372dsDesc.stencilEnabled = true;373dsDesc.depthTestEnabled = true;374dsDesc.stencil.compareOp = Comparison::ALWAYS;375dsDesc.depthCompare = Comparison::LESS_EQUAL;376DepthStencilState *stencilAlwaysDepthTestLessEqual = draw->CreateDepthStencilState(dsDesc);377dsDesc.depthCompare = Comparison::GREATER;378DepthStencilState *stencilAlwaysDepthTestGreater = draw->CreateDepthStencilState(dsDesc);379380dsDesc.stencilEnabled = false;381dsDesc.depthTestEnabled = true;382dsDesc.depthCompare = Comparison::LESS_EQUAL;383DepthStencilState *depthTestLessEqual = draw->CreateDepthStencilState(dsDesc);384dsDesc.depthCompare = Comparison::GREATER;385DepthStencilState *depthTestGreater = draw->CreateDepthStencilState(dsDesc);386387RasterState *rasterNoCull = draw->CreateRasterState({});388389PipelineDesc discardDesc{390Primitive::TRIANGLE_LIST,391{ draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D), discardFragShader_ },392inputLayout, depthStencilWrite, blendOffNoColor, rasterNoCull, &vsColBufDesc,393};394discardWriteDepthStencil_ = draw->CreateGraphicsPipeline(discardDesc, "test");395discardDesc.depthStencil = depthWrite;396discardWriteDepth_ = draw->CreateGraphicsPipeline(discardDesc, "test");397discardDesc.depthStencil = stencilWrite;398discardWriteStencil_ = draw->CreateGraphicsPipeline(discardDesc, "test");399400PipelineDesc testDesc{401Primitive::TRIANGLE_LIST,402{ draw->GetVshaderPreset(VS_TEXTURE_COLOR_2D), draw->GetFshaderPreset(FS_TEXTURE_COLOR_2D) },403inputLayout, stencilEqual, blendOff, rasterNoCull, &vsColBufDesc,404};405drawTestStencilEqual_ = draw->CreateGraphicsPipeline(testDesc, "test");406407testDesc.depthStencil = stencilEqualDepthAlways;408drawTestStencilEqualDepthAlways_ = draw->CreateGraphicsPipeline(testDesc, "test");409410testDesc.depthStencil = stencilNotEqual;411drawTestStencilNotEqual_ = draw->CreateGraphicsPipeline(testDesc, "test");412413testDesc.depthStencil = stenciNotEqualDepthAlways;414drawTestStencilNotEqualDepthAlways_ = draw->CreateGraphicsPipeline(testDesc, "test");415416testDesc.depthStencil = stencilAlwaysDepthTestGreater;417drawTestStencilAlwaysDepthGreater_ = draw->CreateGraphicsPipeline(testDesc, "test");418419testDesc.depthStencil = stencilAlwaysDepthTestLessEqual;420drawTestStencilAlwaysDepthLessEqual_ = draw->CreateGraphicsPipeline(testDesc, "test");421422testDesc.depthStencil = depthTestGreater;423drawTestDepthGreater_ = draw->CreateGraphicsPipeline(testDesc, "test");424425testDesc.depthStencil = depthTestLessEqual;426drawTestDepthLessEqual_ = draw->CreateGraphicsPipeline(testDesc, "test");427428inputLayout->Release();429blendOff->Release();430depthStencilWrite->Release();431stencilEqual->Release();432stencilNotEqual->Release();433stencilEqualDepthAlways->Release();434stenciNotEqualDepthAlways->Release();435stencilAlwaysDepthTestLessEqual->Release();436stencilAlwaysDepthTestGreater->Release();437depthTestLessEqual->Release();438depthTestGreater->Release();439rasterNoCull->Release();440}441442Draw::DrawContext *draw = dc.GetDrawContext();443444static const char * const writeModeNames[] = { "Stencil+Depth", "Stencil", "Depth" };445Pipeline *writePipelines[] = { discardWriteDepthStencil_, discardWriteStencil_, discardWriteDepth_ };446const int numWriteModes = ARRAY_SIZE(writeModeNames);447448static const char * const testNames[] = { "Stenc", "Stenc+DepthA", "Depth", "StencA+Depth" };449Pipeline *testPipeline1[] = { drawTestStencilEqual_, drawTestStencilEqualDepthAlways_, drawTestDepthLessEqual_, drawTestStencilAlwaysDepthLessEqual_ };450Pipeline *testPipeline2[] = { drawTestStencilNotEqual_, drawTestStencilNotEqualDepthAlways_, drawTestDepthGreater_, drawTestStencilAlwaysDepthGreater_ };451const int numTests = ARRAY_SIZE(testNames);452453static const bool validCombinations[numWriteModes][numTests] = {454{true, true, true, true},455{true, true, false, false},456{false, false, true, true},457};458459// Don't want any fancy font texture stuff going on here, so use FLAG_DYNAMIC_ASCII everywhere!460461// We draw the background at Z=0.5 and the text at Z=0.9.462463// Then we draw a rectangle with a depth test or stencil test that should mask out the text.464// Plus a second rectangle with the opposite test.465466// If everything is OK, both the background and the text should be OK.467468Bounds layoutBounds = dc.GetLayoutBounds();469470dc.Begin();471dc.SetFontScale(1.0f, 1.0f);472std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME);473std::string vendor = screenManager()->getDrawContext()->GetInfoString(InfoField::VENDORSTRING);474std::string driver = screenManager()->getDrawContext()->GetInfoString(InfoField::DRIVER);475dc.DrawText(apiName, layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);476dc.DrawText(vendor, layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);477dc.DrawText(driver, layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);478dc.Flush();479480float testW = 170.f;481float padding = 20.0f;482UI::Style style = dc.theme->itemStyle;483484float y = 150;485for (int j = 0; j < numWriteModes; j++, y += 120.f + padding) {486float x = layoutBounds.x + (layoutBounds.w - (float)numTests * testW - (float)(numTests - 1) * padding) / 2.0f;487dc.Begin();488dc.DrawText(writeModeNames[j], layoutBounds.x + padding, y + 40, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);489dc.Flush();490for (int i = 0; i < numTests; i++, x += testW + padding) {491if (!validCombinations[j][i])492continue;493dc.Begin();494Bounds bounds = { x, y + 40, testW, 70 };495dc.DrawText(testNames[i], bounds.x, y, style.fgColor, FLAG_DYNAMIC_ASCII);496dc.Flush();497498dc.BeginPipeline(writePipelines[j], samplerNearest_);499// Draw the rectangle with stencil value 0, depth 0.1f and the text with stencil 0xFF, depth 0.9. Then set 0xFF as the stencil value and draw the rectangles at depth 0.5.500501draw->SetStencilParams(0, 0xFF, 0xFF);502dc.SetCurZ(0.1f);503dc.FillRect(UI::Drawable(bgColorBAD), bounds);504// test bounds505dc.Flush();506507draw->SetStencilParams(0xff, 0xFF, 0xFF);508dc.SetCurZ(0.9f);509dc.DrawTextRect("TEST OK", bounds, textColorBAD, ALIGN_HCENTER | ALIGN_VCENTER | FLAG_DYNAMIC_ASCII);510dc.Flush();511512// Draw rectangle that should result in the text513dc.BeginPipeline(testPipeline1[i], samplerNearest_);514draw->SetStencilParams(0xff, 0, 0xFF);515dc.SetCurZ(0.5f);516dc.FillRect(UI::Drawable(textColorOK), bounds);517dc.Flush();518519// Draw rectangle that should result in the bg520dc.BeginPipeline(testPipeline2[i], samplerNearest_);521draw->SetStencilParams(0xff, 0, 0xFF);522dc.SetCurZ(0.5f);523dc.FillRect(UI::Drawable(bgColorOK), bounds);524dc.Flush();525}526}527dc.Flush();528}529530void GPUDriverTestScreen::ShaderTest(UIContext &dc) {531using namespace Draw;532533Draw::DrawContext *draw = dc.GetDrawContext();534535if (!adrenoLogicDiscardPipeline_) {536adrenoLogicDiscardFragShader_ = CreateShader(draw, ShaderStage::Fragment, fsAdrenoLogicTest);537adrenoLogicDiscardVertShader_ = CreateShader(draw, ShaderStage::Vertex, vsAdrenoLogicTest);538539flatFragShader_ = CreateShader(draw, ShaderStage::Fragment, fsFlat);540flatVertShader_ = CreateShader(draw, ShaderStage::Vertex, vsFlat);541542InputLayout *inputLayout = ui_draw2d.CreateInputLayout(draw);543// No blending used.544BlendState *blendOff = draw->CreateBlendState({ false, 0xF });545546// No depth or stencil, we only use discard in this test.547DepthStencilStateDesc dsDesc{};548dsDesc.depthTestEnabled = false;549dsDesc.depthWriteEnabled = false;550DepthStencilState *depthStencilOff = draw->CreateDepthStencilState(dsDesc);551552RasterState *rasterNoCull = draw->CreateRasterState({});553554PipelineDesc adrenoLogicDiscardDesc{555Primitive::TRIANGLE_LIST,556{ adrenoLogicDiscardVertShader_, adrenoLogicDiscardFragShader_ },557inputLayout, depthStencilOff, blendOff, rasterNoCull, &vsColBufDesc,558};559adrenoLogicDiscardPipeline_ = draw->CreateGraphicsPipeline(adrenoLogicDiscardDesc, "test");560561PipelineDesc flatDesc{562Primitive::TRIANGLE_LIST,563{ flatVertShader_, flatFragShader_ },564inputLayout, depthStencilOff, blendOff, rasterNoCull, &vsColBufDesc,565};566flatShadingPipeline_ = draw->CreateGraphicsPipeline(flatDesc, "test");567568inputLayout->Release();569blendOff->Release();570depthStencilOff->Release();571rasterNoCull->Release();572}573574Bounds layoutBounds = dc.GetLayoutBounds();575576dc.Begin();577dc.SetFontScale(1.0f, 1.0f);578std::string apiName = screenManager()->getDrawContext()->GetInfoString(InfoField::APINAME);579std::string vendor = screenManager()->getDrawContext()->GetInfoString(InfoField::VENDORSTRING);580std::string driver = screenManager()->getDrawContext()->GetInfoString(InfoField::DRIVER);581dc.DrawText(apiName, layoutBounds.centerX(), 20, 0xFFFFFFFF, ALIGN_CENTER);582dc.DrawText(vendor, layoutBounds.centerX(), 60, 0xFFFFFFFF, ALIGN_CENTER);583dc.DrawText(driver, layoutBounds.centerX(), 100, 0xFFFFFFFF, ALIGN_CENTER);584dc.Flush();585586float y = layoutBounds.y + 150;587float x = layoutBounds.x + 10;588dc.Begin();589dc.DrawText("Adreno logic", x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);590dc.Flush();591592float testW = 170.f;593594Bounds bounds = { x + 200, y, testW, 70 };595596// Draw rectangle that should result in the bg597dc.Begin();598dc.FillRect(UI::Drawable(bgColorOK), bounds);599dc.Flush();600601// Draw text on it using the shader.602dc.BeginPipeline(adrenoLogicDiscardPipeline_, samplerNearest_);603dc.DrawTextRect("TEST OK", bounds, textColorOK, ALIGN_HCENTER | ALIGN_VCENTER | FLAG_DYNAMIC_ASCII);604dc.Flush();605606y += 100;607608dc.Begin();609dc.DrawText("Flat shaded tex", x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);610dc.DrawText("(TEST OK if logo but no gradient!)", x + 400, y, 0xFFFFFFFF, ALIGN_LEFT);611dc.Flush();612613bounds = { x + 200, y, 100, 100 };614615// Draw rectangle that should be flat shaded616dc.BeginPipeline(flatShadingPipeline_, samplerNearest_);617// There is a "provoking vertex" difference here between GL and Vulkan when using flat shading. One gets one color, one gets the other.618// However, we now use the VK_EXT_provoking_vertex extension to make it match up (and match with the PSP).619dc.DrawImageVGradient(ImageID("I_ICON"), 0xFFFFFFFF, 0xFF808080, bounds);620dc.Flush();621622y += 120;623624dc.Begin();625dc.DrawText("Test done", x, y, 0xFFFFFFFF, FLAG_DYNAMIC_ASCII);626dc.Flush();627}628629void GPUDriverTestScreen::DrawForeground(UIContext &dc) {630switch (tabHolder_->GetCurrentTab()) {631case 0:632DiscardTest(dc);633break;634case 1:635ShaderTest(dc);636break;637}638}639640641