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

Add ALU ocuppancy Knob #534

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
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
43 changes: 43 additions & 0 deletions assets/benchmarks/shaders/Benchmark_Texture-100.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "Benchmark_Quad.hlsli"

Texture2D Tex[10] : register(t1); // Slot 0 is used by push constant.
RWStructuredBuffer<float> dataBuffer : register(u11);

float4 psmain(VSOutputPos input) : SV_TARGET
{
uint32_t textureCount = Config.TextureCount;
float4 color1 = {0.0f, 0.0f, 0.0f, 0.0f};
float4 color2 = {0.0f, 0.0f, 0.0f, 0.0f};
float4 color3 = {0.0f, 0.0f, 0.0f, 0.0f};
for(uint32_t i = 0; i < textureCount; i++)
{
color1 += Tex[i].Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
}
for(uint32_t i = 0; i < textureCount; i++)
{
color2 += Tex[i].Load(uint3(input.position.x, input.position.y, 0));
}
for(uint32_t i = 0; i < textureCount; i++)
{
color3 += Tex[i].Load(uint3(input.position.x + 1, input.position.y + 1, 0))/float(textureCount);
}
float4 color = color1 + 0.5f * color2 + 0.25f * color3;
if (!any(color))
dataBuffer[0] = color.r;
color.a = randomCompute(Config.InstCount, input.position);
return color;
}
42 changes: 42 additions & 0 deletions assets/benchmarks/shaders/Benchmark_Texture-62.hlsl
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// Copyright 2023 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

#include "Benchmark_Quad.hlsli"

Texture2D Tex[10] : register(t1); // Slot 0 is used by push constant.
RWStructuredBuffer<float> dataBuffer : register(u11);

float4 psmain(VSOutputPos input) : SV_TARGET
{
uint32_t textureCount = Config.TextureCount;
float4 color1 = {0.0f, 0.0f, 0.0f, 0.0f};
float4 color2 = {0.0f, 0.0f, 0.0f, 0.0f};

for(uint32_t i = 0; i < textureCount; i++)
{
color1 += Tex[i].Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
}

for(uint32_t i = 0; i < textureCount; i++)
{
color2 += Tex[i].Load(uint3(input.position.x, input.position.y, 0));
}

float4 color = color1 + 0.5f * color2;

if (!any(color))
dataBuffer[0] = color.r;
color.a = randomCompute(Config.InstCount, input.position);
return color;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,16 @@ RWStructuredBuffer<float> dataBuffer : register(u11);
float4 psmain(VSOutputPos input) : SV_TARGET
{
uint32_t textureCount = Config.TextureCount;
float4 color = {0.0f, 0.0f, 0.0f, 0.0f};
float4 color1 = {0.0f, 0.0f, 0.0f, 0.0f};

for(uint32_t i = 0; i < textureCount; i++)
{
color += Tex[i].Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
color1 += Tex[i].Load(uint3(input.position.x, input.position.y, 0))/float(textureCount);
}

float4 color = color1;
if (!any(color))
dataBuffer[0] = color.r;
color.a = randomCompute(Config.InstCount, input.position);
color.a = randomCompute(Config.InstCount, input.position);
return color;
}
}
14 changes: 12 additions & 2 deletions assets/benchmarks/shaders/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,18 @@ generate_rules_for_shader("shader_benchmark_solid_color"
INCLUDES "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Quad.hlsli"
STAGES "ps")

generate_rules_for_shader("shader_benchmark_texture"
SOURCE "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Texture.hlsl"
generate_rules_for_shader("shader_benchmark_texture-75"
SOURCE "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Texture-75.hlsl"
INCLUDES "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Quad.hlsli"
STAGES "ps")

generate_rules_for_shader("shader_benchmark_texture-100"
SOURCE "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Texture-100.hlsl"
INCLUDES "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Quad.hlsli"
STAGES "ps")

generate_rules_for_shader("shader_benchmark_texture-62"
SOURCE "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Texture-62.hlsl"
INCLUDES "${PPX_DIR}/assets/benchmarks/shaders/Benchmark_Quad.hlsli"
STAGES "ps")

Expand Down
6 changes: 4 additions & 2 deletions benchmarks/graphics_pipeline/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ project(graphics_pipeline)

add_samples_for_all_apis(
NAME ${PROJECT_NAME}
SOURCES
SOURCES
"FreeCamera.h"
"FreeCamera.cpp"
"GraphicsBenchmarkApp.h"
Expand All @@ -34,6 +34,8 @@ add_samples_for_all_apis(
"shader_benchmark_random_noise"
"shader_benchmark_skybox"
"shader_benchmark_solid_color"
"shader_benchmark_texture"
"shader_benchmark_texture-75"
"shader_benchmark_texture-100"
"shader_benchmark_texture-62"
"shader_benchmark_vs_simple_quads"
"shader_fullscreen_triangle")
28 changes: 27 additions & 1 deletion benchmarks/graphics_pipeline/GraphicsBenchmarkApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,11 @@ void GraphicsBenchmarkApp::InitKnobs()
pFullscreenQuadsType->SetFlagDescription("Select the type of the fullscreen quads. See also `--fullscreen-quads-count`.");
pFullscreenQuadsType->SetIndent(1);

GetKnobManager().InitKnob(&pTextureShaderALU, "alu-ocupancy-level", /* defaultValue = */ 0, /* minValue = */ 0, 3);
pTextureShaderALU->SetDisplayName("ALU ocuppancy level for texture shader.");
pTextureShaderALU->SetFlagDescription("Select occupancy level: 0 -> 75, 1 -> 100, 2 -> 62.");
pTextureShaderALU->SetVisible(false);

GetKnobManager().InitKnob(&pFullscreenQuadsColor, "fullscreen-quads-color", 0, kFullscreenQuadsColors);
pFullscreenQuadsColor->SetDisplayName("Color");
pFullscreenQuadsColor->SetFlagDescription("Select the hue for the solid color fullscreen quads. See also `--fullscreen-quads-count`.");
Expand Down Expand Up @@ -542,7 +547,28 @@ void GraphicsBenchmarkApp::SetupFullscreenQuadsResources()
SetupShader("Benchmark_VsSimpleQuads.vs", &mVSQuads);
SetupShader("Benchmark_RandomNoise.ps", &mQuadsPs[0]);
SetupShader("Benchmark_SolidColor.ps", &mQuadsPs[1]);
SetupShader("Benchmark_Texture.ps", &mQuadsPs[2]);
// We choose a shader based on ALU occupancy
switch (pTextureShaderALU->GetValue()) {
case 0:
// This shader has 75% of ALU occupancy
SetupShader("Benchmark_Texture-75.ps", &mQuadsPs[2]);
break;

case 1:
// This shader has 100% of ALU occupancy
SetupShader("Benchmark_Texture-100.ps", &mQuadsPs[2]);
break;

case 2:
// This shader has 62% of ALU occupancy
SetupShader("Benchmark_Texture-62.ps", &mQuadsPs[2]);
break;

default:
// This shader has 75% of ALU occupancy
// We use it as default since it has less operations
SetupShader("Benchmark_Texture-75.ps", &mQuadsPs[2]);
}
}

void GraphicsBenchmarkApp::UpdateSkyBoxDescriptors()
Expand Down
1 change: 1 addition & 0 deletions benchmarks/graphics_pipeline/GraphicsBenchmarkApp.h
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ class GraphicsBenchmarkApp

std::shared_ptr<KnobSlider<int>> pFullscreenQuadsCount;
std::shared_ptr<KnobDropdown<FullscreenQuadsType>> pFullscreenQuadsType;
std::shared_ptr<KnobFlag<int>> pTextureShaderALU;
std::shared_ptr<KnobDropdown<float3>> pFullscreenQuadsColor;
std::shared_ptr<KnobCheckbox> pFullscreenQuadsSingleRenderpass;
std::shared_ptr<KnobFlag<std::string>> pQuadTextureFile;
Expand Down
Loading