Texture/TextureView APIs
| 1079 | |
| 1080 | // Texture/TextureView APIs |
| 1081 | CGPUTextureId cgpu_create_texture(CGPUDeviceId device, const struct CGPUTextureDescriptor* desc) |
| 1082 | { |
| 1083 | SkrCZoneN(zz, "CGPUCreateTexture", 1); |
| 1084 | |
| 1085 | cgpu_assert(device != CGPU_NULLPTR && "fatal: call on NULL device!"); |
| 1086 | cgpu_assert(device->proc_table_cache->create_texture && "create_texture Proc Missing!"); |
| 1087 | CGPUTextureDescriptor new_desc; |
| 1088 | memcpy(&new_desc, desc, sizeof(CGPUTextureDescriptor)); |
| 1089 | if (desc->array_size == 0) new_desc.array_size = 1; |
| 1090 | if (desc->mip_levels == 0) new_desc.mip_levels = 1; |
| 1091 | if (desc->depth == 0) new_desc.depth = 1; |
| 1092 | if (desc->sample_count == 0) new_desc.sample_count = 1; |
| 1093 | CGPUProcCreateTexture fn_create_texture = device->proc_table_cache->create_texture; |
| 1094 | CGPUTexture* texture = (CGPUTexture*)fn_create_texture(device, &new_desc); |
| 1095 | CGPUTextureInfo* info = (CGPUTextureInfo*)texture->info; |
| 1096 | texture->device = device; |
| 1097 | info->sample_count = desc->sample_count; |
| 1098 | |
| 1099 | SkrCZoneEnd(zz); |
| 1100 | |
| 1101 | return texture; |
| 1102 | } |
| 1103 | |
| 1104 | void cgpu_free_texture(CGPUTextureId texture) |
| 1105 | { |