blob: 61537cdcfb6b23447b1269e41372d65a9905c17d [file] [log] [blame]
daniel@transgaming.com4834ee22013-01-11 04:06:16 +00001//
2// Copyright (c) 2012 The ANGLE Project Authors. All rights reserved.
3// Use of this source code is governed by a BSD-style license that can be
4// found in the LICENSE file.
5//
6
7// TextureStorage11.cpp: Implements the abstract rx::TextureStorage11 class and its concrete derived
8// classes TextureStorage11_2D and TextureStorage11_Cube, which act as the interface to the D3D11 texture.
9
10#include "libGLESv2/renderer/TextureStorage11.h"
11
12#include "libGLESv2/renderer/Renderer11.h"
13#include "libGLESv2/renderer/RenderTarget11.h"
14#include "libGLESv2/renderer/SwapChain11.h"
15#include "libGLESv2/renderer/renderer11_utils.h"
16
17#include "libGLESv2/main.h"
18
19namespace rx
20{
21
22TextureStorage11::TextureStorage11(Renderer *renderer, UINT bindFlags)
23 : mBindFlags(bindFlags),
daniel@transgaming.comb1154552013-01-11 04:11:02 +000024 mLodOffset(0),
25 mMipLevels(0)
daniel@transgaming.com4834ee22013-01-11 04:06:16 +000026{
27 mRenderer = Renderer11::makeRenderer11(renderer);
28}
29
30TextureStorage11::~TextureStorage11()
31{
daniel@transgaming.com1e1b5e92013-01-11 04:11:27 +000032}
daniel@transgaming.com4834ee22013-01-11 04:06:16 +000033
34TextureStorage11 *TextureStorage11::makeTextureStorage11(TextureStorage *storage)
35{
36 ASSERT(dynamic_cast<TextureStorage11*>(storage) != NULL);
37 return static_cast<TextureStorage11*>(storage);
38}
39
40DWORD TextureStorage11::GetTextureBindFlags(DXGI_FORMAT format, GLenum glusage, bool forceRenderable)
41{
42 UINT bindFlags = D3D11_BIND_SHADER_RESOURCE;
43
44 if (format == DXGI_FORMAT_D24_UNORM_S8_UINT)
45 {
46 bindFlags |= D3D11_BIND_DEPTH_STENCIL;
47 }
48 else if(forceRenderable || (TextureStorage11::IsTextureFormatRenderable(format) && (glusage == GL_FRAMEBUFFER_ATTACHMENT_ANGLE)))
49 {
50 bindFlags |= D3D11_BIND_RENDER_TARGET;
51 }
52 return bindFlags;
53}
54
55bool TextureStorage11::IsTextureFormatRenderable(DXGI_FORMAT format)
56{
57 switch(format)
58 {
59 case DXGI_FORMAT_R8G8B8A8_UNORM:
60 case DXGI_FORMAT_A8_UNORM:
61 case DXGI_FORMAT_R32G32B32A32_FLOAT:
62 case DXGI_FORMAT_R32G32B32_FLOAT:
63 case DXGI_FORMAT_R16G16B16A16_FLOAT:
64 case DXGI_FORMAT_B8G8R8A8_UNORM:
65 case DXGI_FORMAT_R8_UNORM:
66 case DXGI_FORMAT_R8G8_UNORM:
67 case DXGI_FORMAT_R16_FLOAT:
68 case DXGI_FORMAT_R16G16_FLOAT:
69 return true;
70 case DXGI_FORMAT_BC1_UNORM:
71 case DXGI_FORMAT_BC2_UNORM:
72 case DXGI_FORMAT_BC3_UNORM:
73 return false;
74 default:
75 UNREACHABLE();
76 return false;
77 }
78}
79
80UINT TextureStorage11::getBindFlags() const
81{
82 return mBindFlags;
83}
84
85int TextureStorage11::getLodOffset() const
86{
87 return mLodOffset;
88}
89
90bool TextureStorage11::isRenderTarget() const
91{
92 return (mBindFlags & (D3D11_BIND_RENDER_TARGET | D3D11_BIND_DEPTH_STENCIL)) != 0;
93}
94
95bool TextureStorage11::isManaged() const
96{
97 return false;
98}
99
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000100int TextureStorage11::levelCount()
101{
102 int levels = 0;
103 if (getBaseTexture())
104 {
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000105 levels = mMipLevels - getLodOffset();
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000106 }
107 return levels;
108}
109
daniel@transgaming.com9a2f54d2013-01-11 04:06:36 +0000110UINT TextureStorage11::getSubresourceIndex(int level, int faceIndex)
111{
112 UINT index = 0;
113 if (getBaseTexture())
114 {
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000115 index = D3D11CalcSubresource(level, faceIndex, mMipLevels);
daniel@transgaming.com9a2f54d2013-01-11 04:06:36 +0000116 }
117 return index;
118}
119
120bool TextureStorage11::updateSubresourceLevel(ID3D11Texture2D *srcTexture, int level, int face, GLint xoffset, GLint yoffset, GLsizei width, GLsizei height)
121{
122 if (srcTexture)
123 {
124 D3D11_BOX srcBox;
125 srcBox.left = xoffset;
126 srcBox.top = yoffset;
127 srcBox.right = xoffset + width;
128 srcBox.bottom = yoffset + height;
129 srcBox.front = 0;
130 srcBox.back = 1;
131
132 ID3D11DeviceContext *context = mRenderer->getDeviceContext();
133
134 ASSERT(getBaseTexture());
135 context->CopySubresourceRegion(getBaseTexture(), getSubresourceIndex(level, face), xoffset, yoffset, 0, srcTexture, 0, &srcBox);
136 return true;
137 }
138
139 return false;
140}
141
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000142TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, SwapChain11 *swapchain)
143 : TextureStorage11(renderer, D3D11_BIND_RENDER_TARGET | D3D11_BIND_SHADER_RESOURCE)
144{
145 ID3D11Texture2D *surfaceTexture = swapchain->getOffscreenTexture();
146 mTexture = surfaceTexture;
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000147 mSRV = NULL;
daniel@transgaming.com5cdd0582013-01-11 04:07:35 +0000148 mRenderTarget = NULL;
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000149
150 D3D11_TEXTURE2D_DESC desc;
151 surfaceTexture->GetDesc(&desc);
152
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000153 mMipLevels = desc.MipLevels;
154
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000155 initializeSRV(desc.Format, desc.MipLevels);
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000156 initializeRenderTarget(desc.Format, desc.Width, desc.Height);
157}
158
159TextureStorage11_2D::TextureStorage11_2D(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, GLsizei width, GLsizei height)
160 : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable))
161{
162 mTexture = NULL;
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000163 mSRV = NULL;
daniel@transgaming.com5cdd0582013-01-11 04:07:35 +0000164 mRenderTarget = NULL;
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000165 DXGI_FORMAT format = gl_d3d11::ConvertTextureFormat(internalformat);
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000166
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000167 // if the width or height is not positive this should be treated as an incomplete texture
168 // we handle that here by skipping the d3d texture creation
169 if (width > 0 && height > 0)
170 {
171 // adjust size if needed for compressed textures
172 gl::MakeValidSize(false, gl::IsCompressed(internalformat), &width, &height, &mLodOffset);
173
174 ID3D11Device *device = mRenderer->getDevice();
175
176 D3D11_TEXTURE2D_DESC desc;
177 desc.Width = width; // Compressed texture size constraints?
178 desc.Height = height;
179 desc.MipLevels = levels + mLodOffset;
180 desc.ArraySize = 1;
181 desc.Format = format;
182 desc.SampleDesc.Count = 1;
183 desc.SampleDesc.Quality = 0;
184 desc.Usage = D3D11_USAGE_DEFAULT;
185 desc.BindFlags = getBindFlags();
186 desc.CPUAccessFlags = 0;
187 desc.MiscFlags = 0;
188
189 HRESULT result = device->CreateTexture2D(&desc, NULL, &mTexture);
190
191 if (FAILED(result))
192 {
193 ASSERT(result == E_OUTOFMEMORY);
194 ERR("Creating image failed.");
195 error(GL_OUT_OF_MEMORY);
196 }
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000197 else
198 {
199 mTexture->GetDesc(&desc);
200 mMipLevels = desc.MipLevels;
201 }
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000202 }
203
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000204 initializeSRV(format, levels + mLodOffset);
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000205 initializeRenderTarget(format, width, height);
206}
207
208TextureStorage11_2D::~TextureStorage11_2D()
209{
210 if (mTexture)
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000211 {
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000212 mTexture->Release();
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000213 mTexture = NULL;
214 }
daniel@transgaming.com1e1b5e92013-01-11 04:11:27 +0000215
216 if (mSRV)
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000217 {
daniel@transgaming.com1e1b5e92013-01-11 04:11:27 +0000218 mSRV->Release();
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000219 mSRV = NULL;
220 }
221
222 if (mRenderTarget)
223 {
224 for (unsigned int i = 0; i < mMipLevels; i++)
225 {
226 delete mRenderTarget[i];
227 mRenderTarget[i] = NULL;
228 }
229
230 delete[] mRenderTarget;
231 mRenderTarget = NULL;
232 }
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000233}
234
235TextureStorage11_2D *TextureStorage11_2D::makeTextureStorage11_2D(TextureStorage *storage)
236{
237 ASSERT(dynamic_cast<TextureStorage11_2D*>(storage) != NULL);
238 return static_cast<TextureStorage11_2D*>(storage);
239}
240
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000241RenderTarget *TextureStorage11_2D::getRenderTarget(int level) const
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000242{
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000243 if (level < 0 || level >= static_cast<int>(mMipLevels))
244 {
245 return NULL;
246 }
247 else
248 {
249 return mRenderTarget[level];
250 }
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000251}
252
253ID3D11Texture2D *TextureStorage11_2D::getBaseTexture() const
254{
255 return mTexture;
256}
257
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000258ID3D11ShaderResourceView *TextureStorage11_2D::getSRV() const
259{
260 return mSRV;
261}
262
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000263void TextureStorage11_2D::generateMipmap(int level)
264{
265 // TODO
266 UNIMPLEMENTED();
267}
268
269void TextureStorage11_2D::initializeRenderTarget(DXGI_FORMAT format, int width, int height)
270{
daniel@transgaming.com5cdd0582013-01-11 04:07:35 +0000271 ASSERT(mRenderTarget == NULL);
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000272
273 if (mTexture != NULL && isRenderTarget())
274 {
275 if (getBindFlags() & D3D11_BIND_RENDER_TARGET)
276 {
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000277 mRenderTarget = new RenderTarget11*[mMipLevels];
278 for (unsigned i = 0; i < mMipLevels; i++)
279 {
280 // Create render target view -- texture should already be created with
281 // BIND_RENDER_TARGET flag.
282 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
283 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;
284 rtvDesc.Format = format;
285 rtvDesc.Texture2D.MipSlice = i;
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000286
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000287 ID3D11RenderTargetView *renderTargetView;
288 ID3D11Device *device = mRenderer->getDevice();
289 HRESULT result = device->CreateRenderTargetView(mTexture, &rtvDesc, &renderTargetView);
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000290
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000291 if (result == E_OUTOFMEMORY)
292 return;
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000293
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000294 ASSERT(SUCCEEDED(result));
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000295
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000296 mRenderTarget[i] = new RenderTarget11(mRenderer, renderTargetView, std::max(width >> i, 1), std::max(height >> i, 1));
297 }
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000298 }
299 else if (getBindFlags() & D3D11_BIND_DEPTH_STENCIL)
300 {
301 // TODO
302 UNIMPLEMENTED();
303 }
304 else
305 UNREACHABLE();
306 }
307}
308
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000309void TextureStorage11_2D::initializeSRV(DXGI_FORMAT format, int levels)
310{
311 ASSERT(mSRV == NULL);
312
313 if (mTexture)
314 {
315 D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
316 srvDesc.Format = format;
317 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURE2D;
318 srvDesc.Texture2D.MostDetailedMip = 0;
daniel@transgaming.coma0b868a2013-01-11 04:08:27 +0000319 srvDesc.Texture2D.MipLevels = (levels == 0 ? -1 : levels);
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000320
321 ID3D11Device *device = mRenderer->getDevice();
322 HRESULT result = device->CreateShaderResourceView(mTexture, &srvDesc, &mSRV);
323
324 if (result == E_OUTOFMEMORY)
325 {
326 return error(GL_OUT_OF_MEMORY);
327 }
328
329 ASSERT(SUCCEEDED(result));
330 }
331}
332
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000333TextureStorage11_Cube::TextureStorage11_Cube(Renderer *renderer, int levels, GLenum internalformat, GLenum usage, bool forceRenderable, int size)
334 : TextureStorage11(renderer, GetTextureBindFlags(gl_d3d11::ConvertTextureFormat(internalformat), usage, forceRenderable))
335{
336 mTexture = NULL;
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000337 mSRV = NULL;
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000338
339 for (unsigned int i = 0; i < 6; ++i)
daniel@transgaming.com5cdd0582013-01-11 04:07:35 +0000340 {
341 mRenderTarget[i] = NULL;
342 }
343
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000344 DXGI_FORMAT format = gl_d3d11::ConvertTextureFormat(internalformat);
345 // if the size is not positive this should be treated as an incomplete texture
346 // we handle that here by skipping the d3d texture creation
347 if (size > 0)
348 {
349 // adjust size if needed for compressed textures
350 int height = size;
351 gl::MakeValidSize(false, gl::IsCompressed(internalformat), &size, &height, &mLodOffset);
352
353 ID3D11Device *device = mRenderer->getDevice();
354
355 D3D11_TEXTURE2D_DESC desc;
356 desc.Width = size;
357 desc.Height = size;
358 desc.MipLevels = levels + mLodOffset;
359 desc.ArraySize = 6;
360 desc.Format = format;
361 desc.SampleDesc.Count = 1;
362 desc.SampleDesc.Quality = 0;
363 desc.Usage = D3D11_USAGE_DEFAULT;
364 desc.BindFlags = getBindFlags();
365 desc.CPUAccessFlags = 0;
366 desc.MiscFlags = D3D11_RESOURCE_MISC_TEXTURECUBE;
367
368 HRESULT result = device->CreateTexture2D(&desc, NULL, &mTexture);
369
370 if (FAILED(result))
371 {
372 ASSERT(result == E_OUTOFMEMORY);
373 ERR("Creating image failed.");
374 error(GL_OUT_OF_MEMORY);
375 }
daniel@transgaming.comb1154552013-01-11 04:11:02 +0000376 else
377 {
378 mTexture->GetDesc(&desc);
379 mMipLevels = desc.MipLevels;
380 }
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000381 }
382
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000383 initializeSRV(format, levels + mLodOffset);
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000384 initializeRenderTarget(format, size);
385}
386
387TextureStorage11_Cube::~TextureStorage11_Cube()
388{
389 if (mTexture)
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000390 {
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000391 mTexture->Release();
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000392 mTexture = NULL;
393 }
daniel@transgaming.com1e1b5e92013-01-11 04:11:27 +0000394
395 if (mSRV)
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000396 {
daniel@transgaming.com1e1b5e92013-01-11 04:11:27 +0000397 mSRV->Release();
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000398 mSRV = NULL;
399 }
400
401 for (unsigned int i = 0; i < 6; i++)
402 {
403 if (mRenderTarget[i])
404 {
405 for (unsigned int j = 0; j < mMipLevels; j++)
406 {
407 delete mRenderTarget[i][j];
408 mRenderTarget[i][j] = NULL;
409 }
410
411 delete[] mRenderTarget[i];
412 mRenderTarget[i] = NULL;
413 }
414 }
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000415}
416
417TextureStorage11_Cube *TextureStorage11_Cube::makeTextureStorage11_Cube(TextureStorage *storage)
418{
419 ASSERT(dynamic_cast<TextureStorage11_Cube*>(storage) != NULL);
420 return static_cast<TextureStorage11_Cube*>(storage);
421}
422
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000423RenderTarget *TextureStorage11_Cube::getRenderTarget(GLenum faceTarget, int level) const
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000424{
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000425 if (level < 0 || level >= static_cast<int>(mMipLevels))
426 {
427 return NULL;
428 }
429 else
430 {
431 return mRenderTarget[gl::TextureCubeMap::faceIndex(faceTarget)][level];
432 }
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000433}
434
435ID3D11Texture2D *TextureStorage11_Cube::getBaseTexture() const
436{
437 return mTexture;
438}
439
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000440ID3D11ShaderResourceView *TextureStorage11_Cube::getSRV() const
441{
442 return mSRV;
443}
444
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000445void TextureStorage11_Cube::generateMipmap(int face, int level)
446{
447 // TODO
448 UNIMPLEMENTED();
449}
450
451void TextureStorage11_Cube::initializeRenderTarget(DXGI_FORMAT format, int size)
452{
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000453 if (mTexture != NULL && isRenderTarget())
454 {
455 if (getBindFlags() & D3D11_BIND_RENDER_TARGET)
456 {
457 // Create render target view -- texture should already be created with
458 // BIND_RENDER_TARGET flag.
459
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000460 for (unsigned int i = 0; i < 6; ++i)
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000461 {
daniel@transgaming.com5cdd0582013-01-11 04:07:35 +0000462 ASSERT(mRenderTarget[i] == NULL);
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000463 mRenderTarget[i] = new RenderTarget11*[mMipLevels];
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000464
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000465 for (unsigned int j = 0; j < mMipLevels; j++)
466 {
467 D3D11_RENDER_TARGET_VIEW_DESC rtvDesc;
468 rtvDesc.Format = format;
469 rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2DARRAY;
470 rtvDesc.Texture2DArray.MipSlice = j;
471 rtvDesc.Texture2DArray.FirstArraySlice = i;
472 rtvDesc.Texture2DArray.ArraySize = 1;
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000473
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000474 ID3D11RenderTargetView *renderTargetView;
475 ID3D11Device *device = mRenderer->getDevice();
476 HRESULT result = device->CreateRenderTargetView(mTexture, &rtvDesc, &renderTargetView);
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000477
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000478 if (result == E_OUTOFMEMORY)
479 return;
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000480
shannon.woods@transgaming.com4b472352013-01-25 21:14:56 +0000481 ASSERT(SUCCEEDED(result));
482
483 int mipSize = size >> j;
484 mRenderTarget[i][j] = new RenderTarget11(mRenderer, renderTargetView, mipSize, mipSize);
485 }
daniel@transgaming.comb2151e52013-01-11 04:06:24 +0000486 }
487 }
488 else if (getBindFlags() & D3D11_BIND_DEPTH_STENCIL)
489 {
490 // TODO
491 UNIMPLEMENTED();
492 }
493 else
494 UNREACHABLE();
495 }
496}
497
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000498void TextureStorage11_Cube::initializeSRV(DXGI_FORMAT format, int levels)
499{
500 ASSERT(mSRV == NULL);
501
502 if (mTexture)
503 {
504 D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
505 srvDesc.Format = format;
506 srvDesc.ViewDimension = D3D11_SRV_DIMENSION_TEXTURECUBE;
daniel@transgaming.coma0b868a2013-01-11 04:08:27 +0000507 srvDesc.TextureCube.MipLevels = (levels == 0 ? -1 : levels);
daniel@transgaming.comb50d5302013-01-11 04:07:29 +0000508 srvDesc.TextureCube.MostDetailedMip = 0;
509
510 ID3D11Device *device = mRenderer->getDevice();
511 HRESULT result = device->CreateShaderResourceView(mTexture, &srvDesc, &mSRV);
512
513 if (result == E_OUTOFMEMORY)
514 {
515 return error(GL_OUT_OF_MEMORY);
516 }
517
518 ASSERT(SUCCEEDED(result));
519 }
520}
521
daniel@transgaming.com4834ee22013-01-11 04:06:16 +0000522}