当前位置: 首页>>代码示例>>C++>>正文


C++ StateWriter::beginMember方法代码示例

本文整理汇总了C++中StateWriter::beginMember方法的典型用法代码示例。如果您正苦于以下问题:C++ StateWriter::beginMember方法的具体用法?C++ StateWriter::beginMember怎么用?C++ StateWriter::beginMember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在StateWriter的用法示例。


在下文中一共展示了StateWriter::beginMember方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

static void
dumpShaders(StateWriter &writer, ID3D10Device *pDevice)
{
    writer.beginMember("shaders");
    writer.beginObject();

    com_ptr<ID3D10VertexShader> pVertexShader;
    pDevice->VSGetShader(&pVertexShader);
    if (pVertexShader) {
        dumpShader<ID3D10DeviceChild>(writer, "VS", pVertexShader);
    }

    com_ptr<ID3D10GeometryShader> pGeometryShader;
    pDevice->GSGetShader(&pGeometryShader);
    if (pGeometryShader) {
        dumpShader<ID3D10DeviceChild>(writer, "GS", pGeometryShader);
    }

    com_ptr<ID3D10PixelShader> pPixelShader;
    pDevice->PSGetShader(&pPixelShader);
    if (pPixelShader) {
        dumpShader<ID3D10DeviceChild>(writer, "PS", pPixelShader);
    }

    writer.endObject();
    writer.endMember(); // shaders
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:27,代码来源:d3d10state.cpp

示例2: glGetProgramivARB

static inline void
dumpArbProgram(StateWriter &writer, Context &context, GLenum target)
{
    if (context.ES ||
        context.core ||
        !glIsEnabled(target)) {
        return;
    }

    GLint program_length = 0;
    glGetProgramivARB(target, GL_PROGRAM_LENGTH_ARB, &program_length);
    if (!program_length) {
        return;
    }

    GLchar *source = new GLchar[program_length + 1];
    source[0] = 0;
    glGetProgramStringARB(target, GL_PROGRAM_STRING_ARB, source);
    source[program_length] = 0;

    writer.beginMember(enumToString(target));
    writer.writeString(source);
    writer.endMember();

    delete [] source;
}
开发者ID:Innovative-Ideas,项目名称:apitrace,代码行数:26,代码来源:glstate_shaders.cpp

示例3: getPrivateData

inline void
dumpShader(StateWriter &writer, const char *name, T *pShader) {
    if (!pShader) {
        return;
    }

    /*
     * There is no method to get the shader byte code, so the creator is supposed to
     * attach it via the SetPrivateData method.
     */


    std::vector<BYTE> ShaderBytecode = getPrivateData(pShader, GUID_D3DSTATE);
    if (ShaderBytecode.empty()) {
        return;
    }

    com_ptr<IDisassemblyBuffer> pDisassembly;
    HRESULT hr;
    hr = DisassembleShader(&ShaderBytecode[0], ShaderBytecode.size(), &pDisassembly);
    if (SUCCEEDED(hr)) {
        writer.beginMember(name);
        writer.writeString((const char *)pDisassembly->GetBufferPointer() /*, pDisassembly->GetBufferSize() */);
        writer.endMember();
    }
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:26,代码来源:d3d10state.hpp

示例4: 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
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:47,代码来源:d3d8state_images.cpp

示例5: 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
}
开发者ID:byhj,项目名称:apitrace,代码行数:46,代码来源:d3d10state_images.cpp

示例6: dumpStateObjectDesc

static void
dumpRasterizerState(StateWriter &writer, ID3D10Device *pDevice)
{
    com_ptr<ID3D10RasterizerState> pRasterizerState;

    pDevice->RSGetState(&pRasterizerState);
    writer.beginMember("RasterizerState");
    dumpStateObjectDesc(writer, pRasterizerState);
    writer.endMember(); // RasterizerState
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:10,代码来源:d3d10state.cpp

示例7: dumpProgramUniforms

static void
dumpProgramUniformsStage(StateWriter &writer, GLint program, const char *stage)
{
    if (program <= 0) {
        return;
    }

    writer.beginMember(stage);
    writer.beginObject();
    dumpProgramUniforms(writer, program);
    writer.endObject();
    writer.endMember();
}
开发者ID:Innovative-Ideas,项目名称:apitrace,代码行数:13,代码来源:glstate_shaders.cpp

示例8: 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
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:37,代码来源:d3d8state_images.cpp

示例9: dumpRasterizerState

static void
dumpParameters(StateWriter &writer, ID3D10Device *pDevice)
{
    // TODO: dump description of current bound state
    writer.beginMember("parameters");
    writer.beginObject();

    dumpRasterizerState(writer, pDevice);
    dumpBlendState(writer, pDevice);
    dumpDepthStencilState(writer, pDevice);
    dumpViewports(writer, pDevice);
    dumpScissors(writer, pDevice);

    writer.endObject();
    writer.endMember(); // parameters
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:16,代码来源:d3d10state.cpp

示例10: dumpStateObject

static void
dumpViewports(StateWriter &writer, ID3D10Device *pDevice)
{
   D3D10_VIEWPORT vps[D3D10_VIEWPORT_AND_SCISSORRECT_OBJECT_COUNT_PER_PIPELINE];
   UINT numViewports = 0, i;

   pDevice->RSGetViewports(&numViewports, NULL);
   pDevice->RSGetViewports(&numViewports, vps);

   writer.beginMember("Viewports");
   writer.beginArray();
   for (i = 0; i < numViewports; ++i) {
      dumpStateObject(writer, vps[i]);
   }
   writer.endArray();
   writer.endMember();
}
开发者ID:Dhanasekahar,项目名称:apitrace,代码行数:17,代码来源:d3d10state.cpp

示例11: ARRAYSIZE

void
dumpTextures(StateWriter &writer, ID3D10Device *pDevice)
{
    writer.beginMember("textures");
    writer.beginObject();

    ID3D10ShaderResourceView *pShaderResourceViews[D3D10_COMMONSHADER_SAMPLER_SLOT_COUNT];

    pDevice->PSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
    dumpStageTextures(writer, pDevice, "PS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);

    pDevice->VSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
    dumpStageTextures(writer, pDevice, "VS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);

    pDevice->GSGetShaderResources(0, ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);
    dumpStageTextures(writer, pDevice, "GS", ARRAYSIZE(pShaderResourceViews), pShaderResourceViews);

    writer.endObject();
    writer.endMember(); // textures
}
开发者ID:byhj,项目名称:apitrace,代码行数:20,代码来源:d3d10state_images.cpp

示例12: dumpAttrib

static void
dumpAttribArray(StateWriter &writer,
                const std::string & name,
                const AttribDesc &desc,
                const GLbyte *data)
{
    writer.beginMember(name);
    if (desc.size > 1) {
        writer.beginArray();
    }

    for (GLint i = 0; i < desc.size; ++i) {
        const GLbyte *row = data + desc.arrayStride*i;

        dumpAttrib(writer, desc, row);
    }

    if (desc.size > 1) {
        writer.endArray();
    }
    writer.endMember();
}
开发者ID:Innovative-Ideas,项目名称:apitrace,代码行数:22,代码来源:glstate_shaders.cpp

示例13: glGetIntegerv

void
dumpShadersUniforms(StateWriter &writer, Context &context)
{
    GLint pipeline = 0;
    GLint vertex_program = 0;
    GLint fragment_program = 0;
    GLint geometry_program = 0;
    GLint tess_control_program = 0;
    GLint tess_evaluation_program = 0;
    GLint compute_program = 0;

    if (!context.ES) {
        glGetIntegerv(GL_PROGRAM_PIPELINE_BINDING, &pipeline);
        if (pipeline) {
            glGetProgramPipelineiv(pipeline, GL_VERTEX_SHADER, &vertex_program);
            glGetProgramPipelineiv(pipeline, GL_FRAGMENT_SHADER, &fragment_program);
            glGetProgramPipelineiv(pipeline, GL_GEOMETRY_SHADER, &geometry_program);
            glGetProgramPipelineiv(pipeline, GL_TESS_CONTROL_SHADER, &tess_control_program);
            glGetProgramPipelineiv(pipeline, GL_TESS_EVALUATION_SHADER, &tess_evaluation_program);
            glGetProgramPipelineiv(pipeline, GL_COMPUTE_SHADER, &compute_program);
        }
    }

    GLint program = 0;
    if (!pipeline) {
        glGetIntegerv(GL_CURRENT_PROGRAM, &program);
    }

    writer.beginMember("shaders");
    writer.beginObject();
    if (pipeline) {
        dumpProgram(writer, context, vertex_program);
        dumpProgram(writer, context, fragment_program);
        dumpProgram(writer, context, geometry_program);
        dumpProgram(writer, context, tess_control_program);
        dumpProgram(writer, context, tess_evaluation_program);
        dumpProgram(writer, context, compute_program);
    } else if (program) {
        dumpProgram(writer, context, program);
    } else {
        dumpArbProgram(writer, context, GL_FRAGMENT_PROGRAM_ARB);
        dumpArbProgram(writer, context, GL_VERTEX_PROGRAM_ARB);
    }
    writer.endObject();
    writer.endMember(); // shaders

    writer.beginMember("uniforms");
    writer.beginObject();
    if (pipeline) {
        dumpProgramUniformsStage(writer, vertex_program, "GL_VERTEX_SHADER");
        dumpProgramUniformsStage(writer, fragment_program, "GL_FRAGMENT_SHADER");
        dumpProgramUniformsStage(writer, geometry_program, "GL_GEOMETRY_SHADER");
        dumpProgramUniformsStage(writer, tess_control_program, "GL_TESS_CONTROL_SHADER");
        dumpProgramUniformsStage(writer, tess_evaluation_program, "GL_TESS_EVALUATION_SHADER");
        dumpProgramUniformsStage(writer, compute_program, "GL_COMPUTE_SHADER");
    } else if (program) {
        dumpProgramUniforms(writer, program);
    } else {
        dumpArbProgramUniforms(writer, context, GL_FRAGMENT_PROGRAM_ARB, "fp.");
        dumpArbProgramUniforms(writer, context, GL_VERTEX_PROGRAM_ARB, "vp.");
    }
    writer.endObject();
    writer.endMember(); // uniforms

    writer.beginMember("buffers");
    writer.beginObject();
    if (!context.ES) {
        if (pipeline) {
            dumpVertexAttributes(writer, context, vertex_program);
        } else {
            dumpVertexAttributes(writer, context, program);
        }
        if (program) {
            dumpTransformFeedback(writer, program);
        }
    }
    writer.endObject();
    writer.endMember(); // buffers
}
开发者ID:Innovative-Ideas,项目名称:apitrace,代码行数:79,代码来源:glstate_shaders.cpp

示例14: desc


//.........这里部分代码省略.........
        }

        GLint buffer = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING, &buffer);
        if (!buffer) {
            continue;
        }



        GLint size = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_SIZE, &size);
        GLint type = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_TYPE, &type);
        GLint normalized = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_NORMALIZED, &normalized);
        GLint stride = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_STRIDE, &stride);
        GLvoid * pointer = 0;
        glGetVertexAttribPointerv(location, GL_VERTEX_ATTRIB_ARRAY_POINTER, &pointer);

        GLint offset = reinterpret_cast<intptr_t>(pointer);
        assert(offset >= 0);

        GLint divisor = 0;
        glGetVertexAttribiv(location, GL_VERTEX_ATTRIB_ARRAY_DIVISOR, &divisor);
        if (divisor) {
            // TODO: not clear the best way of presenting instanced attibutes on the dump
            std::cerr << "warning: dumping of instanced attributes (" << &name[0] << ") not yet supported\n";
            return;
        }

        if (size == GL_BGRA) {
            std::cerr << "warning: dumping of GL_BGRA attributes (" << &name[0] << ") not yet supported\n";
            size = 4;
        }

        AttribDesc desc(type, size);
        if (!desc) {
            std::cerr << "warning: dumping of packed attribute (" << &name[0] << ") not yet supported\n";
            // TODO: handle
            continue;
        }

        attribs.emplace_back();
        VertexAttrib &attrib = attribs.back();
        attrib.name = &name[0];

        // TODO handle normalized attributes
        if (normalized) {
            std::cerr << "warning: dumping of normalized attribute (" << &name[0] << ") not yet supported\n";
        }

        attrib.desc = desc;
        GLsizei attribSize = attrib.desc.arrayStride;

        if (stride == 0) {
            // tightly packed
            stride = attribSize;
        }

        attrib.offset = offset;
        attrib.stride = stride;

        BufferMapping &mapping = mappings[buffer];
        attrib.map = (const GLbyte *)mapping.map(GL_ARRAY_BUFFER, buffer);

        BufferBinding bb(GL_ARRAY_BUFFER, buffer);
        GLint bufferSize = 0;
        glGetBufferParameteriv(GL_ARRAY_BUFFER, GL_BUFFER_SIZE, &bufferSize);

        if (bufferSize <= offset ||
            bufferSize <= offset + attribSize) {
            return;
        } else {
            unsigned attribCount = (bufferSize - offset - attribSize)/stride + 1;
            count = std::min(count, attribCount);
        }
    }

    if (count == 0 || count == ~0U || attribs.empty()) {
        return;
    }

    writer.beginMember("vertices");
    writer.beginArray();
    for (unsigned vertex = 0; vertex < count; ++vertex) {
        writer.beginObject();
        for (auto attrib : attribs) {
            const AttribDesc & desc = attrib.desc;
            assert(desc);

            const GLbyte *vertex_data = attrib.map + attrib.stride*vertex + attrib.offset;
            dumpAttribArray(writer, attrib.name, desc, vertex_data);
        }
        writer.endObject();
    }
    writer.endArray();
    writer.endMember();
}
开发者ID:Innovative-Ideas,项目名称:apitrace,代码行数:101,代码来源:glstate_shaders.cpp

示例15: 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;
        }

    }
}
开发者ID:byhj,项目名称:apitrace,代码行数:77,代码来源:d3d10state_images.cpp


注:本文中的StateWriter::beginMember方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。