Skip to content

Commit

Permalink
pipeline statistics.
Browse files Browse the repository at this point in the history
  • Loading branch information
bluesky013 committed Sep 22, 2023
1 parent 7e53d99 commit 3ffa5cf
Show file tree
Hide file tree
Showing 66 changed files with 991 additions and 215 deletions.
15 changes: 15 additions & 0 deletions cocos/gfx/base/define.ts
Original file line number Diff line number Diff line change
Expand Up @@ -701,6 +701,19 @@ export enum PassType {
PRESENT,
}

export enum PipelineStatisticFlagBit {
NONE = 0,
IA_VERTICES = 0x01,
IA_PRIMITIVES = 0x02,
VS_INVOCATIONS = 0x04,
CLIP_INVOCATIONS = 0x08,
CLIP_PRIMITIVES = 0x10,
FS_INVOCATIONS = 0x20,
CS_INVOCATIONS = 0x40,
ALL = IA_VERTICES | IA_PRIMITIVES | VS_INVOCATIONS | CLIP_INVOCATIONS | CLIP_PRIMITIVES
| FS_INVOCATIONS | CS_INVOCATIONS,
}

export type BufferUsage = BufferUsageBit;
export type BufferFlags = BufferFlagBit;
export type MemoryAccess = MemoryAccessBit;
Expand All @@ -712,6 +725,7 @@ export type ShaderStageFlags = ShaderStageFlagBit;
export type AccessFlags = AccessFlagBit;
export type DynamicStateFlags = DynamicStateFlagBit;
export type ClearFlags = ClearFlagBit;
export type PipelineStatisticFlags = PipelineStatisticFlagBit;

export class Size {
declare private _token: never; // to make sure all usages must be an instance of this exact class, not assembled from plain object
Expand Down Expand Up @@ -754,6 +768,7 @@ export class DeviceCaps {
public maxComputeWorkGroupInvocations: number = 0,
public maxComputeWorkGroupSize: Size = new Size(),
public maxComputeWorkGroupCount: Size = new Size(),
public timestampPeriod: number = 1,
public supportQuery: boolean = false,
public clipSpaceMinZ: number = -1,
public screenSpaceSignY: number = 1,
Expand Down
53 changes: 47 additions & 6 deletions cocos/gfx/base/device.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,43 @@
*/

import {
API, Feature, MemoryStatus,
CommandBufferInfo, BufferInfo, BufferViewInfo, TextureInfo, TextureViewInfo, SamplerInfo, DescriptorSetInfo,
ShaderInfo, InputAssemblerInfo, RenderPassInfo, FramebufferInfo, DescriptorSetLayoutInfo, PipelineLayoutInfo,
QueueInfo, BufferTextureCopy, DeviceInfo, DeviceCaps, GeneralBarrierInfo, TextureBarrierInfo, BufferBarrierInfo,
SwapchainInfo, BindingMappingInfo, Format, FormatFeature, TextureType, TextureUsageBit,
TextureFlagBit, Offset, Extent, SampleCount, TextureSubresLayers, TextureUsage, TextureFlags,
API,
Feature,
MemoryStatus,
CommandBufferInfo,
BufferInfo,
BufferViewInfo,
TextureInfo,
TextureViewInfo,
SamplerInfo,
DescriptorSetInfo,
ShaderInfo,
InputAssemblerInfo,
RenderPassInfo,
FramebufferInfo,
DescriptorSetLayoutInfo,
PipelineLayoutInfo,
QueueInfo,
BufferTextureCopy,
DeviceInfo,
DeviceCaps,
GeneralBarrierInfo,
TextureBarrierInfo,
BufferBarrierInfo,
SwapchainInfo,
BindingMappingInfo,
Format,
FormatFeature,
TextureType,
TextureUsageBit,
TextureFlagBit,
Offset,
Extent,
SampleCount,
TextureSubresLayers,
TextureUsage,
TextureFlags,
PipelineStatisticFlags,
} from './define';
import { Buffer } from './buffer';
import { CommandBuffer } from './command-buffer';
Expand Down Expand Up @@ -370,6 +401,16 @@ export abstract class Device {
public getMaxSampleCount (format: Format, usage: TextureUsage, flags: TextureFlags): SampleCount {
return SampleCount.X1;
}

/**
* @en Get supported pipeline statistic flags by device query.
* @zh 获取可通过设备查询获取的管线硬件数据类型
* @param flags Pipeline statistic flag to be tested.
* @param outFlags Pipeline statistic flag test result.
*/
public getSupportedPipelineStatisticFlags (flags: Readonly<PipelineStatisticFlags>, outFlags: PipelineStatisticFlags): number {
return 0;
}
}

export class DefaultResource {
Expand Down
29 changes: 18 additions & 11 deletions editor/assets/effects/internal/builtin-debug-renderer.effect
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
CCEffect %{
techniques:
- passes:
- vert: debug-renderer-vs:vert
frag: debug-renderer-fs:frag
- vert: debug-renderer-vs
frag: debug-renderer-fs
priority: max
depthStencilState:
depthTest: false
Expand All @@ -20,8 +20,14 @@ CCEffect %{

CCProgram debug-renderer-vs %{
precision mediump float;
#include <builtin/uniforms/cc-global>
#include <common/common-define>

#pragma rate CCGlobal pass
layout(set = 0, binding = 1) uniform CCGlobal {
mediump vec4 cc_surfaceTransform; // 0: orientation, 1: flip
mediump vec4 cc_screenSize;
};

#define CC_HANDLE_GET_CLIP_FLIP(uv) uv = cc_surfaceTransform.y == 0.0 ? vec2(uv.x, -uv.y) : uv

in vec2 a_position;
in vec2 a_texCoord;
Expand All @@ -30,7 +36,7 @@ CCProgram debug-renderer-vs %{
out vec2 v_texCoord;
out vec4 v_color;

vec4 vert () {
void main () {
int orientation = int(cc_surfaceTransform.x);
vec4 transform = vec4(1.0, 0.0, 0.0, 1.0);

Expand All @@ -54,21 +60,22 @@ CCProgram debug-renderer-vs %{
v_texCoord = a_texCoord;
v_color = a_color;

return vec4(clipPos, 0.0, 1.0);
gl_Position = vec4(clipPos, 0.0, 1.0);
}
}%

CCProgram debug-renderer-fs %{
precision mediump float;
#include <legacy/output>

in vec2 v_texCoord;
in vec4 v_color;

uniform sampler2D mainTexture;
#pragma rate mainTexture pass
layout(set = 0, binding = 0) uniform sampler2D mainTexture;

layout(location = 0) out vec4 outColor;

vec4 frag () {
vec4 color = vec4(v_color.rgb, v_color.a * texture(mainTexture, v_texCoord).r);
return CCFragOutput(color);
void main () {
outColor = vec4(v_color.rgb, v_color.a * texture(mainTexture, v_texCoord).r);
}
}%
4 changes: 4 additions & 0 deletions native/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1467,6 +1467,10 @@ cocos_source_files(
cocos/renderer/pipeline/custom/details/SerializationUtils.h
cocos/renderer/pipeline/custom/details/Set.h
cocos/renderer/pipeline/custom/details/Utility.h
cocos/renderer/pipeline/profile/GPUTimeQuery.cpp
cocos/renderer/pipeline/profile/GPUTimeQuery.h
cocos/renderer/pipeline/profile/PipelineProfiler.cpp
cocos/renderer/pipeline/profile/PipelineProfiler.h
)

if (USE_GEOMETRY_RENDERER)
Expand Down
3 changes: 2 additions & 1 deletion native/cocos/bindings/jswrapper/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
THE SOFTWARE IS PRO
VIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
Expand Down
4 changes: 1 addition & 3 deletions native/cocos/core/assets/Font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,7 @@ FontFace::FontFace(Font *font)
}

FontFace::~FontFace() {
for (auto *texture : _textures) {
CC_SAFE_DESTROY_AND_DELETE(texture);
}
_textures.clear();
}

/**
Expand Down
5 changes: 3 additions & 2 deletions native/cocos/core/assets/Font.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#pragma once
#include "base/std/container/unordered_map.h"
#include "base/std/container/vector.h"
#include "base/Ptr.h"
#include "core/assets/Asset.h"

namespace cc {
Expand Down Expand Up @@ -107,7 +108,7 @@ class FontFace {
inline Font *getFont() const { return _font; }
inline uint32_t getFontSize() const { return _fontSize; }
inline uint32_t getLineHeight() const { return _lineHeight; }
inline const ccstd::vector<gfx::Texture *> &getTextures() const { return _textures; }
inline const ccstd::vector<IntrusivePtr<gfx::Texture>> &getTextures() const { return _textures; }
inline gfx::Texture *getTexture(uint32_t page) const { return _textures[page]; }
inline uint32_t getTextureWidth() const { return _textureWidth; }
inline uint32_t getTextureHeight() const { return _textureHeight; }
Expand All @@ -120,7 +121,7 @@ class FontFace {
uint32_t _lineHeight{0U};
ccstd::unordered_map<uint32_t, FontGlyph> _glyphs;
ccstd::unordered_map<KerningPair, float, KerningHash> _kernings;
ccstd::vector<gfx::Texture *> _textures;
ccstd::vector<IntrusivePtr<gfx::Texture>> _textures;
uint32_t _textureWidth{0U};
uint32_t _textureHeight{0U};
};
Expand Down
Loading

0 comments on commit 3ffa5cf

Please sign in to comment.