Cogs.Core
TexturesGLES30.cpp
1#include "TexturesGLES30.h"
2
3#include <algorithm>
4
5#include "FormatsGLES30.h"
6#include "CapabilitiesGLES30.h"
7#include "ContextGLES30.h"
8
9#include "Foundation/Logging/Logger.h"
10
11using namespace Cogs;
12
13namespace
14{
15 Cogs::Logging::Log logger = Cogs::Logging::getLogger("TexturesGLES30");
16
17
18 Cogs::TextureHandle logAndReturnInvalidHandle(const Cogs::TextureDescription& desc)
19 {
20 LOG_ERROR(logger, "Illegal %s description (width=%u, height=%u, depth=%u, layers=%u, faces=%u, levels=%u, samples=%u)",
21 getResourceDimensionsName(desc.target), desc.width, desc.height, desc.depth, desc.layers, desc.faces, desc.levels, desc.samples);
23 }
24
25 // Clamp the sample count to max supported for a particular format
26 uint32_t clampFormatSampleCount(CapabilitiesGLES30* caps, Cogs::TextureFormat format, uint8_t numSamples)
27 {
28 const OpenGLES30::DataFormatInfo& fmt = OpenGLES30::DataFormats[size_t(format)];
29
30 // Clamp sample count
31 GLint maxSampleCount = 0;
32 glGetInternalformativ(GL_RENDERBUFFER, fmt.internalFormat, GL_SAMPLES, 1, &maxSampleCount);
33 assert(0 <= maxSampleCount);
34
35 if (caps->getDeviceCapabilities().MaxSamples < static_cast<unsigned>(maxSampleCount)) {
36 LOG_WARNING_ONCE(logger, "getInternalFormat(fmt=0x%04x) returned maxSampleCount=%d, but glGetIntegerv(GL_MAX_SAMPLES) returned %u, clamping.",
37 fmt.internalFormat, maxSampleCount, caps->getDeviceCapabilities().MaxSamples);
38 maxSampleCount = caps->getDeviceCapabilities().MaxSamples;
39 }
40 if (uint32_t(maxSampleCount) < numSamples) {
41 LOG_DEBUG_ONCE(logger, "Requested sample count %u greater than maximum %d for format %s, clamping.",
42 numSamples, maxSampleCount, getFormatInfo(format)->name);
43 return maxSampleCount;
44 }
45 return numSamples;
46 }
47
48}
49
51{
52 const bool generateMips = (desc.flags & TextureFlags::GenerateMipMaps) != 0;
53
54 TextureGLES30 texture{ };
55 texture.width = desc.width;
56 texture.height = desc.height;
57 texture.depth = 1;
58 texture.estimatedByteSize = uint32_t(desc.estimateMemorySize());
59 texture.flags = desc.flags;
60 texture.numSamples = uint8_t(desc.samples);
61 texture.textureId = 0;
62 texture.renderBuffer = 0;
63 texture.fbo = 0;
64 texture.format = desc.format;
65 texture.cubeMap = false;
66 texture.hasMipmaps = generateMips || desc.levels > 1;
67
68 // Sanity checks
69 const OpenGLES30::DataFormatInfo& fmt = OpenGLES30::DataFormats[size_t(texture.format)];
70 if (fmt.isTextureFormat == 0) {
72 }
73 if (data && fmt.isCompressed) {
74 texture.estimatedByteSize = uint32_t(data->getSize());
75 }
76
77 switch (desc.target) {
78 case ResourceDimensions::Unknown:
79 case ResourceDimensions::Buffer:
80 case ResourceDimensions::Texture1D:
81 case ResourceDimensions::Texture1DArray:
82 case ResourceDimensions::Texture3DArray:
83 case ResourceDimensions::TextureCubeArray:
84 case ResourceDimensions::Texture2DMSArray:
85 LOG_ERROR(logger, "Unsupported texture resource dimension %s", getResourceDimensionsName(desc.target));
87
88 case ResourceDimensions::Texture2DMS:
89 if (desc.width == 0 || desc.height == 0 || desc.depth != 1 || desc.layers != 1 || desc.faces != 1 || desc.samples == 0) {
90 return logAndReturnInvalidHandle(desc);
91 }
92 else {
93 texture.target = GL_TEXTURE_2D_MULTISAMPLE; // Not directly supported, used to specify that data is in a renderbuffer
94
95 texture.numSamples = static_cast<uint8_t>(clampFormatSampleCount(caps, texture.format, texture.numSamples));
96
97 // Set up renderbuffer
98 glGenRenderbuffers(1, &texture.renderBuffer);
99 glBindRenderbuffer(GL_RENDERBUFFER, texture.renderBuffer);
100 glRenderbufferStorageMultisample(GL_RENDERBUFFER, texture.numSamples, fmt.internalFormat, texture.width, texture.height);
101 glBindRenderbuffer(GL_RENDERBUFFER, 0);
102
103 // Set up framebuffer
104 GLenum framebufferAttachment = (texture.flags & Cogs::TextureFlags::DepthBuffer) ? GL_DEPTH_ATTACHMENT : GL_COLOR_ATTACHMENT0;
105 glGenFramebuffers(1, &texture.fbo);
106 glBindFramebuffer(GL_READ_FRAMEBUFFER, texture.fbo);
107 glFramebufferRenderbuffer(GL_READ_FRAMEBUFFER, framebufferAttachment, GL_RENDERBUFFER, texture.renderBuffer);
108 glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);
109
110 GLenum status = glCheckFramebufferStatus(GL_READ_FRAMEBUFFER);
111 if (status != GL_FRAMEBUFFER_COMPLETE) {
112 LOG_ERROR(logger, "Failed to create multisample texture rendertarget: %s", OpenGLES30::framebuffersStatusString(status));
113 glDeleteFramebuffers(1, &texture.fbo);
114 glDeleteRenderbuffers(1, &texture.renderBuffer);
116 }
117
118 return textures.addResource(texture);
119 }
120 break;
121
122 case ResourceDimensions::Texture2D:
123 if (desc.width == 0 || desc.height == 0 || desc.depth != 1 || desc.layers != 1 || desc.faces != 1 || desc.samples != 1) {
124 return logAndReturnInvalidHandle(desc);
125 }
126 texture.target = GL_TEXTURE_2D;
127 break;
128 case ResourceDimensions::Texture2DArray:
129 if (desc.width == 0 || desc.height == 0 || desc.depth != 1 || desc.layers == 0 || desc.faces != 1 || desc.samples != 1) {
130 return logAndReturnInvalidHandle(desc);
131 }
132 texture.target = GL_TEXTURE_2D_ARRAY;
133 texture.depth = desc.layers;
134 break;
135 case ResourceDimensions::Texture3D:
136 if (desc.width == 0 || desc.height == 0 || desc.depth == 0 || desc.layers != 1 || desc.faces != 1 || desc.samples != 1) {
137 return logAndReturnInvalidHandle(desc);
138 }
139 texture.target = GL_TEXTURE_3D;
140 texture.depth = desc.depth;
141 break;
142 case ResourceDimensions::TextureCube:
143 if (desc.width == 0 || desc.height == 0 || desc.depth != 1 || desc.layers != 1 || desc.faces != 6 || desc.samples != 1) {
144 return logAndReturnInvalidHandle(desc);
145 }
146 texture.target = GL_TEXTURE_CUBE_MAP;
147 texture.depth = desc.depth;
148 texture.cubeMap = true;
149 break;
150
151 case ResourceDimensions::RenderBuffer:
152 if (desc.width == 0 || desc.height == 0 || desc.depth != 1 || desc.layers != 1 || desc.faces != 1 || desc.levels != 1) {
153 return logAndReturnInvalidHandle(desc);
154 }
155 if (generateMips) {
156 LOG_ERROR(logger, "RenderBuffers do not support mipmaps");
158 }
159 texture.target = GL_RENDERBUFFER;
160 texture.numSamples = static_cast<uint8_t>(clampFormatSampleCount(caps, texture.format, texture.numSamples));
161 break;
162 default:
163 assert(false && "Invalid enum");
164 break;
165 }
166
167 GLuint textureLevels;
168 if (generateMips) {
169 textureLevels = 1 + static_cast<GLuint>(std::floor(std::log((double)std::max(desc.width, desc.height)) / std::log(2.0)));
170 }
171 else {
172 textureLevels = static_cast<GLuint>(desc.levels);
173 }
174
175
177
178 // If texture is a render buffer
179 if (texture.target == GL_RENDERBUFFER) {
180
181 texture.textureId = 0;
182 if (texture.flags & TextureFlags::ExternalTexture) {
183 assert(data != nullptr);
184 texture.renderBuffer = static_cast<GLuint>(data->externalHandle);
185 }
186 else {
187 glGenRenderbuffers(1, &texture.renderBuffer);
188 glBindRenderbuffer(GL_RENDERBUFFER, texture.renderBuffer);
189 glRenderbufferStorageMultisample(GL_RENDERBUFFER, texture.numSamples, fmt.internalFormat, texture.width, texture.height);
190 glBindRenderbuffer(GL_RENDERBUFFER, 0);
191 }
192 textureHandle = textures.addResource(texture);
193 }
194
195 // If texture is an actual texture
196 else {
197 if (desc.flags & TextureFlags::ExternalTexture) {
198 assert(data != nullptr);
199 texture.textureId = static_cast<GLuint>(data->externalHandle);
200 textureHandle = textures.addResource(texture);
201
202 if (generateMips) {
203 if (TextureGLES30* tex = context->bindTexture(textureHandle); tex) {
204 glGenerateMipmap(tex->target);
205 }
206 }
207 }
208 else {
209 glGenTextures(1, &texture.textureId);
210 textureHandle = textures.addResource(texture);
211
212 if (TextureGLES30* tex = context->bindTexture(textureHandle); tex) {
213 defineTextureData(tex, textureLevels);
214 if (data) {
215 uploadTextureData(*tex, *data, 0, 0, 0);
216 }
217 else if (generateMips) {
218 glGenerateMipmap(tex->target);
219 }
220 }
221 }
222 }
223
224 textureMemoryConsumption += texture.estimatedByteSize;
225 return textureHandle;
226}
227
228void Cogs::TexturesGLES30::uploadTextureData(TextureGLES30& tex,
229 const TextureData& data,
230 uint32_t layer_offset,
231 uint32_t face_offset,
232 uint32_t level_offset)
233{
234 assert(face_offset == 0 && "face_offset not handled");
235 assert(level_offset == 0 && "level_offset not handled");
236
237 const OpenGLES30::DataFormatInfo& fmt = OpenGLES30::DataFormats[size_t(tex.format)];
238 const bool isCompressed = fmt.isCompressed;
239 const GLenum target = tex.target;
240 const GLenum textureFormat = fmt.internalFormat;
241 const GLenum pixelType = fmt.type;
242 const GLenum pixelFormat = fmt.format;
243
244 if(context->uploadStatisticsEnabled) context->uploadStatisticsTextureUpload(data.getSize());
245
246 if (isCompressed) {
247 switch (target) {
248 case GL_TEXTURE_2D:
249 for (size_t j = 0; j < data.levels; ++j) {
250 TextureExtent ext = data.getExtent(j);
251 glCompressedTexSubImage2D(target, static_cast<GLint>(j), 0, 0, ext.width, ext.height, textureFormat, static_cast<GLsizei>(data.getLevelSize(j)), data.getData(0, 0, j));
252 }
253 break;
254 case GL_TEXTURE_CUBE_MAP:
255 for (size_t j = 0; j < data.levels; ++j) {
256 for (GLint c = 0; c < 6; ++c) {
257 TextureExtent ext = data.getExtent(j);
258 glCompressedTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + c, static_cast<GLint>(j), 0, 0, ext.width, ext.height, textureFormat, GLsizei(data.getLevelSize(j)), data.getData(0, c, j));
259 }
260 }
261 break;
262 case GL_TEXTURE_2D_ARRAY: [[fallthrough]];
263 case GL_TEXTURE_2D_MULTISAMPLE: [[fallthrough]];
264 case GL_TEXTURE_3D: [[fallthrough]];
265 case GL_INVALID_ENUM:
266 LOG_ERROR(logger, "Texture target #%04x cannot use compressed formats", target);
267 break;
268 }
269 }
270 else {
271 switch (target) {
272 case GL_TEXTURE_2D:
273 for (size_t j = 0; j < data.levels; ++j) {
274 TextureExtent ext = data.getExtent(j);
275 glTexSubImage2D(target, static_cast<GLint>(j), 0, 0, ext.width, ext.height, pixelFormat, pixelType, data.getData(0, 0, j));
276 }
277 break;
278 case GL_TEXTURE_2D_ARRAY:
279 for (size_t i = 0; i < data.layers; ++i) {
280 for (size_t j = 0; j < data.levels; ++j) {
281 TextureExtent ext = data.getExtent(j);
282 glTexSubImage3D(target, static_cast<GLint>(j),
283 0, 0, static_cast<GLint>(layer_offset + i), ext.width, ext.height, 1,
284 pixelFormat, pixelType, data.getData(i, 0, j));
285 }
286 }
287 break;
288 case GL_TEXTURE_3D:
289 for (size_t j = 0; j < data.levels; ++j) {
290 TextureExtent ext = data.getExtent(j);
291 glTexSubImage3D(target, static_cast<GLint>(j),
292 0, 0, 0, ext.width, ext.height, ext.depth,
293 pixelFormat, pixelType, data.getData(0, 0, j));
294 }
295 break;
296 case GL_TEXTURE_CUBE_MAP:
297 for (size_t j = 0; j < data.levels; ++j) {
298 for (GLint c = 0; c < 6; ++c) {
299 TextureExtent ext = data.getExtent(j);
300 glTexSubImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X + c, (GLint)j,
301 0, 0, ext.width, ext.height,
302 pixelFormat, pixelType, data.getData(0, c, j));
303 }
304 }
305 break;
306 case GL_TEXTURE_2D_MULTISAMPLE: [[fallthrough]];
307 case GL_INVALID_ENUM:
308 LOG_ERROR(logger, "Texture target #%04x cannot get data uploaded", target);
309 break;
310 }
311 }
312
313 const bool generateMips = (tex.flags & TextureFlags::GenerateMipMaps) != 0;
314 if (generateMips) {
315 glGenerateMipmap(target);
316 }
317}
318
319void Cogs::TexturesGLES30::uploadTextureData(TextureHandle textureHandle,
320 const TextureData& data,
321 uint32_t layer_offset,
322 uint32_t face_offset,
323 uint32_t level_offset)
324{
325 TextureGLES30& texture = this->textures[textureHandle];
326 const GLenum target = texture.target;
327 glBindTexture(target, texture.textureId);
328 uploadTextureData(texture, data, layer_offset, face_offset, level_offset);
329 glBindTexture(target, 0);
330}
331
332
333void Cogs::TexturesGLES30::defineTextureData(TextureGLES30* tex, GLuint textureLevels)
334{
335 const OpenGLES30::DataFormatInfo& fmt = OpenGLES30::DataFormats[size_t(tex->format)];
336 assert(fmt.isTextureFormat);
337
338 switch (tex->target) {
339
340 case GL_TEXTURE_2D:
341 glTexStorage2D(GL_TEXTURE_2D, textureLevels, fmt.internalFormat, tex->width, tex->height);
342 break;
343
344 case GL_TEXTURE_CUBE_MAP:
345 glTexStorage2D(tex->target, textureLevels, fmt.internalFormat, tex->width, tex->height);
346 break;
347
348 case GL_TEXTURE_2D_ARRAY:
349 glTexStorage3D(tex->target, textureLevels, fmt.internalFormat, tex->width, tex->height, tex->depth);
350 break;
351
352 case GL_TEXTURE_3D:
353 glTexStorage3D(tex->target, textureLevels, fmt.internalFormat, tex->width, tex->height, tex->depth);
354 break;
355
356 case GL_TEXTURE_2D_MULTISAMPLE: [[fallthrough]];
357 default:
358 LOG_ERROR(logger, "Texture target #%04x cannot get data uploaded", tex->target);
359 break;
360 }
361}
362
364{
365 if (HandleIsValid(textureHandle)) {
366
367 // Make sure the texture isn't bound
368 for (GLuint i = 0; i < OpenGLES30::maxTexUnits; i++) {
369 if (context->texUnits[i].texture == textureHandle) {
370 if (context->activeTexUnit != i) {
371 context->activeTexUnit = i;
372 glActiveTexture(GL_TEXTURE0 + i);
373 }
374 glBindTexture(context->texUnits[i].target, 0);
375
376 context->texUnits[i].target = GL_TEXTURE_2D;
377 context->texUnits[i].texture = TextureHandle::NoHandle;
378 }
379 }
380
381 // If texture/renderbuffer is external, and NoDelete is not set, we have taken ownership
382 // of the resource and must release it.
383
384 TextureGLES30& texture = textures[textureHandle];
385 if (texture.fbo) {
386 glDeleteFramebuffers(1, &texture.fbo);
387 texture.fbo = 0;
388 }
389 if (texture.renderBuffer) {
390
391 // Don't release it if it is a borrowed renderbuffer
392 if ((texture.target != GL_RENDERBUFFER) || ((texture.flags & TextureFlags::NoDelete) == 0)) {
393 glDeleteRenderbuffers(1, &texture.renderBuffer);
394 }
395 texture.renderBuffer = 0;
396 }
397 // Don't release the texture if it is borrowed
398 if ((texture.textureId != 0) && ((texture.flags & TextureFlags::NoDelete) == 0)) {
399 glDeleteTextures(1, &texture.textureId);
400 }
401 if (texture.textureId != 0) {
402 textureMemoryConsumption -= texture.estimatedByteSize;
403 }
404 texture.textureId = 0;
405
406 textures.removeResource(textureHandle);
407 }
408}
409
410void Cogs::TexturesGLES30::releaseNativeTexture(TextureNativeHandle nativeHandle)
411{
412 GLuint id = (GLuint)(intptr_t)nativeHandle;
413 glDeleteTextures(1, &id);
414}
415
417{
419 LOG_WARNING_ONCE(logger, "loadSamplerState: ES30 does not support border color.");
420 }
421
422 GLuint sampler;
423 glGenSamplers(1, &sampler);
424
425 static const GLenum AddressModes[] = {
426 GL_CLAMP_TO_EDGE,
427 GL_REPEAT,
428 GL_MIRRORED_REPEAT,
429 GL_CLAMP_TO_EDGE
430 };
431 static_assert(sizeof(AddressModes) == sizeof(AddressModes[0]) * Cogs::SamplerState::AddressMode_Size);
432
433 glSamplerParameteri(sampler, GL_TEXTURE_WRAP_S, AddressModes[state.addressModeS]);
434 glSamplerParameteri(sampler, GL_TEXTURE_WRAP_T, AddressModes[state.addressModeT]);
435 glSamplerParameteri(sampler, GL_TEXTURE_WRAP_R, AddressModes[state.addressModeW]);
436
437 static const GLenum ComparisonFunctions[] = {
438 GL_NEVER,
439 GL_LESS,
440 GL_EQUAL,
441 GL_LEQUAL,
442 GL_GREATER,
443 GL_NOTEQUAL,
444 GL_GEQUAL,
445 GL_ALWAYS,
446 };
447 static_assert(sizeof(ComparisonFunctions) == sizeof(ComparisonFunctions[0]) * Cogs::SamplerState::ComparisonFunction_Size);
448
449 if (1 < state.maxAnisotropy) {
450 const GraphicsDeviceCapabilities& deviceCaps = caps->getDeviceCapabilities();
451 float maxAnisotropy = std::min(deviceCaps.MaxAnisotropy, float(state.maxAnisotropy));
452 if (1.f < maxAnisotropy) {
453 glSamplerParameterf(sampler, GL_TEXTURE_MAX_ANISOTROPY_EXT, maxAnisotropy);
454 }
455 }
456
457 switch (state.filter) {
459 glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
460 glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
461 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_NONE);
462 break;
464 glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
465 glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
466 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_NONE);
467 break;
469 glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
470 glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
471 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
472 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_FUNC, ComparisonFunctions[state.comparisonFunction]);
473 break;
474
476 glSamplerParameteri(sampler, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
477 glSamplerParameteri(sampler, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
478 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_REF_TO_TEXTURE);
479 glSamplerParameteri(sampler, GL_TEXTURE_COMPARE_FUNC, ComparisonFunctions[state.comparisonFunction]);
480 break;
481 default:
482 assert(false);
483 }
484
485 return samplers.addResource(SamplerGLES30{ sampler });
486}
487
489{
490 if (HandleIsValid(samplerHandle)) {
491 const SamplerGLES30& sampler = samplers[samplerHandle];
492 glDeleteSamplers(1, &sampler.glName);
493 samplers.removeResource(samplerHandle);
494 }
495}
496
498{
499 if (viewDescription.layerIndex != 0) {
500 LOG_WARNING_ONCE(logger, "Views with nonzero layer index not supported, ignoring");
501 }
502 return views.addResource(viewDescription);
503}
504
506{
507 if (HandleIsValid(handle)) {
508 views.removeResource(handle);
509 }
510}
511
513{
514 if (HandleIsValid(textureHandle)) {
515 const TextureGLES30& tex = textures[textureHandle];
516 if (tex.target == GL_RENDERBUFFER) {
517 return reinterpret_cast<void*>(static_cast<size_t>(tex.renderBuffer));
518 }
519 return reinterpret_cast<void*>(static_cast<size_t>(tex.textureId));
520 }
521 return nullptr;
522}
523
525{
526 TextureGLES30* texture = context->bindTexture(textureHandle);
527 if (texture) {
528 glGenerateMipmap(texture->target);
529 }
530}
531
533{
534 std::vector<TextureHandle> handles;
535 for (TextureGLES30& texture : textures) {
536 handles.push_back(textures.getHandle(texture));
537 }
538 for (TextureHandle& handle : handles) {
539 releaseTexture(handle);
540 }
541}
Log implementation class.
Definition: LogManager.h:140
constexpr Log getLogger(const char(&name)[LEN]) noexcept
Definition: LogManager.h:181
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
const GraphicsDeviceCapabilities & getDeviceCapabilities() const override
Gets the device capabilities in a structure.
Contains device capabilities.
Definition: ICapabilities.h:67
static const Handle_t NoHandle
Represents a handle to nothing.
Definition: Common.h:78
static const Handle_t InvalidHandle
Represents an invalid handle.
Definition: Common.h:81
Encapsulates state for texture sampling in a state object.
Definition: SamplerState.h:12
ComparisonFunction comparisonFunction
Specifies the comparison function to use when applying a comparison sampler.
Definition: SamplerState.h:73
unsigned int maxAnisotropy
Specifies the maximum number of anisotropic samples to use when sampling a texture.
Definition: SamplerState.h:76
AddressMode addressModeW
Specifies the addressing mode along the W axis in texture coordinate space.
Definition: SamplerState.h:67
AddressMode addressModeS
Specifies the addressing mode along the S axis in texture coordinate space.
Definition: SamplerState.h:63
@ Border
Texture color is set to the border color when outside [0, 1] range.
Definition: SamplerState.h:23
@ ComparisonMinMagMipPoint
Comparison filter for depth sample comparisons using point sampling.
Definition: SamplerState.h:38
@ ComparisonMinMagMipLinear
Comparison filter for depth sample comparisons using linear interpolation sampling.
Definition: SamplerState.h:40
@ MinMagMipPoint
Point sampling for both minification and magnification.
Definition: SamplerState.h:33
@ MinMagMipLinear
Linear sampling for both minification and magnification.
Definition: SamplerState.h:35
FilterMode filter
Specifies the filter to use for texture sampling.
Definition: SamplerState.h:70
AddressMode addressModeT
Specifies the addressing mode along the T axis in texture coordinate space.
Definition: SamplerState.h:65
@ DepthBuffer
The texture can be used as a depth target and have depth buffer values written into.
Definition: Flags.h:122
@ NoDelete
The ownership of the underlying texture resource is outside of cogs and cogs will not delete it.
Definition: Flags.h:136
@ GenerateMipMaps
The texture supports automatic mipmap generation performed by the graphics device.
Definition: Flags.h:124
Describes how to fetch data from a texture in shaders.
Definition: ITextures.h:13
uint32_t layerIndex
Index of the first layer (if array) to fetch from.
Definition: ITextures.h:17
void releaseNativeTexture(TextureNativeHandle nativeHandle) override
Release a native texture handle.
void releaseSamplerState(SamplerStateHandle handle)
Release the sampler state with the given handle.
void releaseTexture(TextureHandle textureHandle)
Release the texture with the given textureHandle.
void generateMipmaps(TextureHandle texureHandle)
Use the graphics device to generate mipmaps for the texture with the given texture handle.
void releaseResources()
Release all allocated texture resources.
TextureViewHandle createTextureView(TextureViewDescription &viewDescription) override
Create a texture view used to bind a limited view of the texture data to the rendering pipeline.
void * getNativeHandle(TextureHandle textureHandle) override
Get the device-specific handle (D3D texture pointer, OpenGL texture ID etc) associated with the given...
TextureHandle loadTexture(const TextureDescription &desc, const TextureData *data)
Load a texture from the given description.
void releaseTextureView(const TextureViewHandle &handle) override
Release the given texture view.
SamplerStateHandle loadSamplerState(const SamplerState &state)
Load a sampler state object.