本文整理汇总了C++中StateWriter::writeImage方法的典型用法代码示例。如果您正苦于以下问题:C++ StateWriter::writeImage方法的具体用法?C++ StateWriter::writeImage怎么用?C++ StateWriter::writeImage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StateWriter
的用法示例。
在下文中一共展示了StateWriter::writeImage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getRenderTargetViewImage
void
dumpFramebuffer(StateWriter &writer, ID3D10Device *pDevice)
{
writer.beginMember("framebuffer");
writer.beginObject();
ID3D10RenderTargetView *pRenderTargetViews[D3D10_SIMULTANEOUS_RENDER_TARGET_COUNT];
ID3D10DepthStencilView *pDepthStencilView;
pDevice->OMGetRenderTargets(ARRAYSIZE(pRenderTargetViews), pRenderTargetViews,
&pDepthStencilView);
for (UINT i = 0; i < ARRAYSIZE(pRenderTargetViews); ++i) {
if (!pRenderTargetViews[i]) {
continue;
}
image::Image *image;
image = getRenderTargetViewImage(pDevice, pRenderTargetViews[i]);
if (image) {
char label[64];
_snprintf(label, sizeof label, "RENDER_TARGET_%u", i);
writer.beginMember(label);
writer.writeImage(image);
writer.endMember(); // RENDER_TARGET_*
delete image;
}
pRenderTargetViews[i]->Release();
}
if (pDepthStencilView) {
image::Image *image;
image = getDepthStencilViewImage(pDevice, pDepthStencilView);
if (image) {
writer.beginMember("DEPTH_STENCIL");
writer.writeImage(image);
writer.endMember();
delete image;
}
pDepthStencilView->Release();
}
writer.endObject();
writer.endMember(); // framebuffer
}
示例2: getRenderTargetImage
void
dumpFramebuffer(StateWriter &writer, IDirect3DDevice8 *pDevice)
{
HRESULT hr;
writer.beginMember("framebuffer");
writer.beginObject();
com_ptr<IDirect3DSurface8> pRenderTarget;
hr = pDevice->GetRenderTarget(&pRenderTarget);
if (SUCCEEDED(hr) && pRenderTarget) {
image::Image *image;
image = getRenderTargetImage(pDevice, pRenderTarget);
if (image) {
writer.beginMember("RENDER_TARGET_0");
writer.writeImage(image);
writer.endMember(); // RENDER_TARGET_*
delete image;
}
}
com_ptr<IDirect3DSurface8> pDepthStencil;
hr = pDevice->GetDepthStencilSurface(&pDepthStencil);
if (SUCCEEDED(hr) && pDepthStencil) {
image::Image *image;
image = getSurfaceImage(pDevice, pDepthStencil);
if (image) {
writer.beginMember("DEPTH_STENCIL");
writer.writeImage(image);
writer.endMember(); // RENDER_TARGET_*
delete image;
}
}
writer.endObject();
writer.endMember(); // framebuffer
}
示例3: getTextureImage
void
dumpTextures(StateWriter &writer, IDirect3DDevice8 *pDevice)
{
HRESULT hr;
writer.beginMember("textures");
writer.beginObject();
for (DWORD Stage = 0; Stage < 8; ++Stage) {
com_ptr<IDirect3DBaseTexture8> pTexture;
hr = pDevice->GetTexture(Stage, &pTexture);
if (FAILED(hr)) {
continue;
}
if (!pTexture) {
continue;
}
D3DRESOURCETYPE Type = pTexture->GetType();
DWORD NumFaces = Type == D3DRTYPE_CUBETEXTURE ? 6 : 1;
DWORD NumLevels = pTexture->GetLevelCount();
for (DWORD Face = 0; Face < NumFaces; ++Face) {
for (DWORD Level = 0; Level < NumLevels; ++Level) {
image::Image *image;
image = getTextureImage(pDevice, pTexture, static_cast<D3DCUBEMAP_FACES>(Face), Level);
if (image) {
char label[128];
if (Type == D3DRTYPE_CUBETEXTURE) {
_snprintf(label, sizeof label, "PS_RESOURCE_%lu_FACE_%lu_LEVEL_%lu", Stage, Face, Level);
} else {
_snprintf(label, sizeof label, "PS_RESOURCE_%lu_LEVEL_%lu", Stage, Level);
}
writer.beginMember(label);
writer.writeImage(image);
writer.endMember(); // PS_RESOURCE_*
delete image;
}
}
}
}
writer.endObject();
writer.endMember(); // textures
}
示例4: assert
static void
dumpShaderResourceViewImage(StateWriter &writer,
ID3D10Device *pDevice,
ID3D10ShaderResourceView *pShaderResourceView,
const char *shader,
UINT stage)
{
if (!pShaderResourceView) {
return;
}
com_ptr<ID3D10Resource> pResource;
pShaderResourceView->GetResource(&pResource);
assert(pResource);
D3D10_SHADER_RESOURCE_VIEW_DESC Desc;
pShaderResourceView->GetDesc(&Desc);
UINT MipSlice = 0;
UINT FirstArraySlice = 0;
UINT ArraySize = 1;
switch (Desc.ViewDimension) {
case D3D10_SRV_DIMENSION_BUFFER:
break;
case D3D10_SRV_DIMENSION_TEXTURE1D:
MipSlice = Desc.Texture1D.MostDetailedMip;
break;
case D3D10_SRV_DIMENSION_TEXTURE1DARRAY:
MipSlice = Desc.Texture1DArray.MostDetailedMip;
FirstArraySlice = Desc.Texture1DArray.FirstArraySlice;
ArraySize = Desc.Texture1DArray.ArraySize;
break;
case D3D10_SRV_DIMENSION_TEXTURE2D:
MipSlice = Desc.Texture2D.MostDetailedMip;
break;
case D3D10_SRV_DIMENSION_TEXTURE2DARRAY:
MipSlice = Desc.Texture2DArray.MostDetailedMip;
FirstArraySlice = Desc.Texture2DArray.FirstArraySlice;
ArraySize = Desc.Texture2DArray.ArraySize;
break;
case D3D10_SRV_DIMENSION_TEXTURE2DMS:
break;
case D3D10_SRV_DIMENSION_TEXTURE2DMSARRAY:
FirstArraySlice = Desc.Texture2DMSArray.FirstArraySlice;
ArraySize = Desc.Texture2DMSArray.ArraySize;
break;
case D3D10_SRV_DIMENSION_TEXTURE3D:
MipSlice = Desc.Texture3D.MostDetailedMip;
break;
case D3D10_SRV_DIMENSION_TEXTURECUBE:
MipSlice = Desc.TextureCube.MostDetailedMip;
ArraySize = 6;
break;
case D3D10_SRV_DIMENSION_UNKNOWN:
default:
assert(0);
return;
}
for (UINT ArraySlice = FirstArraySlice; ArraySlice < FirstArraySlice + ArraySize; ++ArraySlice) {
image::Image *image;
image = getSubResourceImage(pDevice, pResource, Desc.Format, ArraySlice, MipSlice);
if (image) {
char label[64];
_snprintf(label, sizeof label,
"%s_RESOURCE_%u_ARRAY_%u_LEVEL_%u",
shader, stage, ArraySlice, MipSlice);
writer.beginMember(label);
writer.writeImage(image);
writer.endMember(); // *_RESOURCE_*
delete image;
}
}
}