6#include "Renderer/RenderTexture.h"
7#include "Resources/TextureManager.h"
9#include "InspectorGuiHelper.h"
23 if (attachment->getType() == Cogs::Core::RenderResourceType::RenderTexture) {
30 else if (texture->
getId() != Cogs::Core::NoResourceId) {
31 header =
"Texture (ID: " + std::to_string(r->
getId()) +
")";
34 header =
"Texture (" + std::to_string(idx++) +
")";
37 header +=
" [" + std::to_string(description->width) +
"x" + std::to_string(description->height);
38 if (description->depth > 1) {
39 header +=
" d:" + std::to_string(description->depth);
41 if (description->samples > 1) {
42 header +=
" s:" + std::to_string(description->samples);
47 if (info && info->
name) {
54 header +=
" RenderTarget";
57 header +=
" DepthBuffer";
60 header +=
" GenerateMipMaps";
66 header +=
" ReadWriteTexture";
69 header +=
" ExternalTexture";
72 header +=
" UsageReadStaging";
74 if (description->flags & Cogs::TextureFlags::UsageWriteStaging) {
75 header +=
" UsageWriteStaging";
78 header +=
" NoDelete";
83 static std::string byteString(
size_t bytes) {
84 if (bytes < 16 * 1024) {
85 return std::to_string(bytes) +
" B";
88 if (bytes < 16 * 1024) {
89 return std::to_string(bytes) +
" KiB";
92 if (bytes < 16 * 1024) {
93 return std::to_string(bytes) +
" MiB";
96 return std::to_string(bytes) +
" GiB";
101void Cogs::Core::textureInspector(Context * context,
bool * show)
104 std::vector<ResourceBase*> allocatedTextures = context->textureManager->getAllocatedResources();
105 std::vector<TextureInfo> textures;
106 std::string windowHeader;
109 windowHeader.reserve(50);
110 windowHeader.append(
"Textures [");
111 windowHeader.append(std::to_string(allocatedTextures.size()));
112 windowHeader.append(
"]###TextureInspector");
114 for (ResourceBase* res : allocatedTextures) {
115 textures.push_back(TextureInfo(res, idx));
117 std::sort(textures.begin(), textures.end(), [](
const TextureInfo& lhs,
const TextureInfo& rhs) { return lhs.header < rhs.header; });
119 guiBegin(windowHeader, show);
121 for (
const TextureInfo& info : textures) {
122 if (ImGui::CollapsingHeader(getUniqueHeader(info.header).c_str())) {
124 RenderResource* attachment = info.texture->getAttachedResource();
126 if (attachment && (attachment->getType() == RenderResourceType::RenderTexture)) {
127 showRenderTexture(context, renderer,
static_cast<RenderTexture*
>(attachment));
130 showTexture(context, renderer, info.texture);
constexpr size_t size() const noexcept
Get the size of the string.
Base class for engine resources.
ResourceId getId() const
Get the resource id of this instance.
StringView getName() const
Get the name of the resource.
RenderResource * getAttachedResource() const
Get the attached resource.
Texture resources contain raster bitmap data to use for texturing.
COGSRENDERING_DLL_API size_t estimateMemorySize() const
Attempts to estimate the amount of memory a texture with these attributes will require.
@ DepthBuffer
The texture can be used as a depth target and have depth buffer values written into.
@ NoDelete
The ownership of the underlying texture resource is outside of cogs and cogs will not delete it.
@ RenderTarget
The texture can be used as a render target and drawn into.
@ GenerateMipMaps
The texture supports automatic mipmap generation performed by the graphics device.
@ ReadWriteTexture
The texture can be used as a read/write texture. Can be used to output data from compute shaders.
@ UsageReadStaging
The texture is intended to be used as a staging texture.
@ CubeMap
The texture can be used as a cube map.