Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test case #2: PS Mem fetch with output #501

Merged
merged 2 commits into from
Aug 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions assets/benchmarks/shaders/Benchmark_Quad.hlsli
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
struct ConfigParams {
uint32_t InstCount;
uint32_t RandomSeed;
uint32_t TextureCount;
float3 ColorValue;
};

Expand Down
36 changes: 35 additions & 1 deletion assets/benchmarks/shaders/Benchmark_Texture.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,42 @@
#include "Benchmark_Quad.hlsli"

Texture2D Tex0 : register(t1); // Slot 0 is used by push constant.
RenfengLiu marked this conversation as resolved.
Show resolved Hide resolved
Texture2D Tex1 : register(t2);
Texture2D Tex2 : register(t3);
Texture2D Tex3 : register(t4);
Texture2D Tex4 : register(t5);
Texture2D Tex5 : register(t6);
Texture2D Tex6 : register(t7);
Texture2D Tex7 : register(t8);
Texture2D Tex8 : register(t9);
Texture2D Tex9 : register(t10);

float4 psmain(VSOutputPos input) : SV_TARGET
{
return Tex0.Load(uint3(input.position.x, input.position.y, /* mipmap */ 0));
Texture2D textureArray[3] = {Tex0, Tex1, Tex2};
uint32_t textureCount = Config.TextureCount;
float4 color = Tex0.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color += Tex1.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
if(textureCount <= 2) {
return color;
}
color += Tex2.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color += Tex3.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
if(textureCount <= 4) {
return color;
}
color += Tex4.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color += Tex5.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
if (textureCount <= 6) {
return color;
}
color += Tex6.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color += Tex7.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
if (textureCount <= 8) {
return color;
}
color += Tex8.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color += Tex9.Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);

return color;
}
Binary file added assets/benchmarks/textures/tiger.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 20 additions & 6 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,10 @@ void GraphicsBenchmarkApp::InitKnobs()
GetKnobManager().InitKnob(&pKnobAluCount, "alu-instruction-count", /* defaultValue = */ 100, /* minValue = */ 100, 400);
pKnobAluCount->SetDisplayName("Number of ALU instructions in the shader");
pKnobAluCount->SetFlagDescription("Select the number of ALU instructions in the shader.");

GetKnobManager().InitKnob(&pKnobTextureCount, "texture-count", /* defaultValue = */ 1, /* minValue = */ 1, kMaxTextureCount);
pKnobTextureCount->SetDisplayName("Number of texture to load in the shader");
pKnobTextureCount->SetFlagDescription("Select the number of texture to load in the shader.");
}

void GraphicsBenchmarkApp::Config(ppx::ApplicationSettings& settings)
Expand Down Expand Up @@ -236,9 +240,9 @@ void GraphicsBenchmarkApp::Setup()
// Descriptor Pool
{
grfx::DescriptorPoolCreateInfo createInfo = {};
createInfo.sampler = 5 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 1 for blit
createInfo.sampledImage = 6 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 1 for quads, 1 for blit
createInfo.uniformBuffer = 2 * GetNumFramesInFlight(); // 1 for skybox, 1 for spheres
createInfo.sampler = 5 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 1 for blit
createInfo.sampledImage = 15 * GetNumFramesInFlight(); // 1 for skybox, 3 for spheres, 10 for quads, 1 for blit
createInfo.uniformBuffer = 2 * GetNumFramesInFlight(); // 1 for skybox, 1 for spheres

PPX_CHECKED_CALL(GetDevice()->CreateDescriptorPool(&createInfo, &mDescriptorPool));
}
Expand Down Expand Up @@ -472,13 +476,18 @@ void GraphicsBenchmarkApp::SetupFullscreenQuadsResources()
{
// Large resolution image
grfx_util::TextureOptions options = grfx_util::TextureOptions().MipLevelCount(1);
PPX_CHECKED_CALL(CreateTextureFromFile(GetDevice()->GetGraphicsQueue(), GetAssetPath(pQuadTextureFile->GetValue()), &mQuadsTexture, options));
for (uint32_t i = 0; i < kMaxTextureCount; i++) {
// Load the same image.
PPX_CHECKED_CALL(CreateTextureFromFile(GetDevice()->GetGraphicsQueue(), GetAssetPath(pQuadTextureFile->GetValue()), &mQuadsTextures[i], options));
}
}

// Descriptor set layout for texture shader
{
grfx::DescriptorSetLayoutCreateInfo layoutCreateInfo = {};
layoutCreateInfo.bindings.push_back(grfx::DescriptorBinding(QUADS_SAMPLED_IMAGE_REGISTER, grfx::DESCRIPTOR_TYPE_SAMPLED_IMAGE));
for (int i = 0; i < kMaxTextureCount; i++) {
layoutCreateInfo.bindings.push_back(grfx::DescriptorBinding(QUADS_SAMPLED_IMAGE_REGISTER + i, grfx::DESCRIPTOR_TYPE_SAMPLED_IMAGE));
}
PPX_CHECKED_CALL(GetDevice()->CreateDescriptorSetLayout(&layoutCreateInfo, &mFullscreenQuads.descriptorSetLayout));
}

Expand Down Expand Up @@ -542,7 +551,9 @@ void GraphicsBenchmarkApp::UpdateFullscreenQuadsDescriptors()
uint32_t n = GetNumFramesInFlight();
for (size_t i = 0; i < n; i++) {
grfx::DescriptorSetPtr pDescriptorSet = mFullscreenQuads.descriptorSets[i];
PPX_CHECKED_CALL(pDescriptorSet->UpdateSampledImage(QUADS_SAMPLED_IMAGE_REGISTER, 0, mQuadsTexture));
for (uint32_t j = 0; j < kMaxTextureCount; j++) {
PPX_CHECKED_CALL(pDescriptorSet->UpdateSampledImage(QUADS_SAMPLED_IMAGE_REGISTER + j, 0, mQuadsTextures[j]));
}
}
}

Expand Down Expand Up @@ -1764,6 +1775,9 @@ void GraphicsBenchmarkApp::RecordCommandBufferFullscreenQuad(PerFrame& frame, si
break;
}
case FullscreenQuadsType::FULLSCREEN_QUADS_TYPE_TEXTURE:
mQuadPushConstant.TextureCount = pKnobTextureCount->GetValue();
frame.cmd->PushGraphicsConstants(mQuadsPipelineInterfaces[0], GetPushConstCount(mQuadPushConstant.TextureCount), &mQuadPushConstant.TextureCount, offsetof(QuadPushConstant, TextureCount) / sizeof(uint32_t));

break;
default:
PPX_ASSERT_MSG(true, "unsupported FullscreenQuadsType: " << static_cast<int>(pFullscreenQuadsType->GetValue()));
Expand Down
7 changes: 5 additions & 2 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,13 @@ static constexpr uint32_t kMaxSphereInstanceCount = 3000;
static constexpr uint32_t kDefaultSphereInstanceCount = 50;
static constexpr uint32_t kSeed = 89977;
static constexpr uint32_t kMaxFullscreenQuadsCount = 1000;
static constexpr uint32_t kMaxTextureCount = 10;

static constexpr float4 kDefaultDrawCallColor = float4(1.0f, 0.175f, 0.365f, 0.5f);
static constexpr uint32_t kDebugColorPushConstantCount = sizeof(float4) / sizeof(uint32_t);

static constexpr const char* kShaderBaseDir = "benchmarks/shaders";
static constexpr const char* kQuadTextureFile = "benchmarks/textures/resolution.jpg";
static constexpr const char* kQuadTextureFile = "benchmarks/textures/tiger.jpg";

enum class DebugView
{
Expand Down Expand Up @@ -432,6 +433,7 @@ class GraphicsBenchmarkApp
{
uint32_t InstCount;
uint32_t RandomSeed;
uint32_t TextureCount;
float3 ColorValue;
};

Expand Down Expand Up @@ -478,7 +480,7 @@ class GraphicsBenchmarkApp
// Fullscreen quads resources
Entity2D mFullscreenQuads;
grfx::ShaderModulePtr mVSQuads;
grfx::TexturePtr mQuadsTexture;
std::array<grfx::TexturePtr, kMaxTextureCount> mQuadsTextures;
QuadPipelineMap mQuadsPipelines;
std::array<grfx::PipelineInterfacePtr, kFullscreenQuadsTypes.size()> mQuadsPipelineInterfaces;
std::array<grfx::ShaderModulePtr, kFullscreenQuadsTypes.size()> mQuadsPs;
Expand Down Expand Up @@ -529,6 +531,7 @@ class GraphicsBenchmarkApp
std::shared_ptr<KnobDropdown<std::pair<int, int>>> pResolution;

std::shared_ptr<KnobFlag<int>> pKnobAluCount;
std::shared_ptr<KnobFlag<int>> pKnobTextureCount;

private:
// =====================================================================
Expand Down
Loading