XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

How to load a texture into Dx10

Last post 05-02-2008 3:52 PM by Ralf Kornmann. 3 replies.
  • 04-26-2008 8:24 PM

    How to load a texture into Dx10

    In my engine i load images from file into memory manually, so i have image data and all of its mipmap levels for all surfaces in the file(if it is a cubemap or tex array) located in separate buffers. The question is how to supply this data to dx10. I see there is a Map method in textures interfaces which allows to map a required part of a resource, but Map cannot be used with D3D10_USAGE_DEFAULT flag. In OpenGL with glTexImage you can supply which data do you load into a given mip level, is there anything like this in dx10?

    I can fill dynamic and staging textures via map/unmap, and for default textures i can use a dynamic temporary texture which after filling will be copied into a default texture via CopyResource, but this approach cannot be applied to immutable textures.

    On the other hand i could use D3D10_SUBRESOURCE_DATA if i knew how to properly layout a texture with all it`s surfaces and mipmaps . For example if i have an arrray of 2 textures with 2 mipmaps per image should i upload data to gpu like this:

    D3D10_SUBRESOURCE_DATA data[4];

    data[0].pSysMem=image(0).mipmap(0);

    data[1].pSysMem=image(0).mipmap(1);

    data[2].pSysMem=image(1).mipmap(0);

    data[3].pSysMem=image(1).mipmap(1);

    The next question is how to arrange cubemap faces into an array of D3D10_SUBRESOURCE_DATA

     

  • 05-01-2008 11:13 AM In reply to

    Re: How to load a texture into Dx10

    The data need to provide in the order of the subresources inside the resource.

    For texture arrays the subresource index is calculated by: MipSlice + (ArraySlice * MipLevels)

    Therefore your example is correct.

    The sides of the cube are stored in the following order:

    +X,-X,+Y,-Y,+Z,-Z

  • 05-02-2008 2:23 PM In reply to

    Re: How to load a texture into Dx10

    Thanks for reply.

    There is one more thing i`d like to know: is it legal to upload compressed(DXTn) 3d images into dx10? Because in OpenGL

    glCompressedTexImage3D always fails for me, so i have to decompress my volume textures in memory.

  • 05-02-2008 3:52 PM In reply to

    Re: How to load a texture into Dx10

    If you create a compressed texture (BC1-BC5) you need to upload compressed data.

Page 1 of 1 (4 items) Previous Next
var gDomain='m.webtrends.com'; var gDcsId='dcschd84w10000w4lw9hcqmsz_8n3x'; var gTrackEvents=1; var gFpc='WT_FPC'; /*<\/scr"+"ipt>");} /*]]>*/
DCSIMG