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


C++ DXCall函数代码示例

本文整理汇总了C++中DXCall函数的典型用法代码示例。如果您正苦于以下问题:C++ DXCall函数的具体用法?C++ DXCall怎么用?C++ DXCall使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: LoadShaders

// Loads resources
void MeshRenderer::Initialize(ID3D11Device* device, ID3D11DeviceContext* context, const Model* model)
{
    this->device = device;

    blendStates.Initialize(device);
    rasterizerStates.Initialize(device);
    depthStencilStates.Initialize(device);
    samplerStates.Initialize(device);

    meshVSConstants.Initialize(device);
    meshPSConstants.Initialize(device);
    shadowConstants.Initialize(device);
    evsmConstants.Initialize(device);
    reductionConstants.Initialize(device);

    LoadShaders();

    D3D11_RASTERIZER_DESC rsDesc = RasterizerStates::NoCullDesc();
    rsDesc.DepthClipEnable = false;
    DXCall(device->CreateRasterizerState(&rsDesc, &noZClipRSState));

    D3D11_SAMPLER_DESC sampDesc = SamplerStates::AnisotropicDesc();
    sampDesc.MaxAnisotropy = ShadowAnisotropy;
    DXCall(device->CreateSamplerState(&sampDesc, &evsmSampler));

    // Create the staging textures for reading back the reduced depth buffer
    for(uint32 i = 0; i < ReadbackLatency; ++i)
        reductionStagingTextures[i].Initialize(device, 1, 1, DXGI_FORMAT_R16G16_UNORM);

    CreateShadowMaps();

    SetModel(model);
}
开发者ID:TheRealMJP,项目名称:LowResRendering,代码行数:34,代码来源:MeshRenderer.cpp

示例2: ResourceUploadBegin

UploadContext ResourceUploadBegin(uint64 size)
{
    Assert_(Device != nullptr);

    size = AlignTo(size, 512);
    Assert_(size <= UploadBufferSize);
    Assert_(size > 0);

    ClearFinishedUploads(0);
    while(AllocUploadSubmission(size) == false)
        ClearFinishedUploads(1);

    Assert_(UploadSubmissionUsed > 0);
    const uint64 submissionIdx = (UploadSubmissionStart + (UploadSubmissionUsed - 1)) % MaxUploadSubmissions;
    UploadSubmission& submission = UploadSubmissions[submissionIdx];
    Assert_(submission.Size == size);

    DXCall(submission.CmdAllocator->Reset());
    DXCall(UploadCmdList->Reset(submission.CmdAllocator, nullptr));

    UploadContext context;
    context.CmdList = UploadCmdList;
    context.Resource = UploadBuffer;
    context.CPUAddress = UploadBufferCPUAddr + submission.Offset;
    context.ResourceOffset = submission.Offset;

    return context;
}
开发者ID:megaes,项目名称:DeferredTexturing,代码行数:28,代码来源:DX12_Upload.cpp

示例3: Assert_

void Profiler::StartProfile(const wstring& name)
{
    ProfileData& profileData = profiles[name];
    Assert_(profileData.QueryStarted == false);
    Assert_(profileData.QueryFinished == false);
    profileData.CPUProfile = false;
    profileData.Active = true;

    if(profileData.DisjointQuery[currFrame] == NULL)
    {
        // Create the queries
        D3D11_QUERY_DESC desc;
        desc.Query = D3D11_QUERY_TIMESTAMP_DISJOINT;
        desc.MiscFlags = 0;
        DXCall(device->CreateQuery(&desc, &profileData.DisjointQuery[currFrame]));

        desc.Query = D3D11_QUERY_TIMESTAMP;
        DXCall(device->CreateQuery(&desc, &profileData.TimestampStartQuery[currFrame]));
        DXCall(device->CreateQuery(&desc, &profileData.TimestampEndQuery[currFrame]));
    }

    // Start a disjoint query first
    context->Begin(profileData.DisjointQuery[currFrame]);

    // Insert the start timestamp
    context->End(profileData.TimestampStartQuery[currFrame]);

    profileData.QueryStarted = true;
}
开发者ID:kingofthebongo2008,项目名称:examples,代码行数:29,代码来源:Profiler.cpp

示例4: DXCall

void MeshRenderer::GenAndCacheMeshInputLayout(const Model* model)
{
	// TODO: optimize this; group meshes with the same input layout to reduce api calls
    for(uint64 i = 0; i < model->Meshes().size(); ++i)
    {
        const Mesh& mesh = model->Meshes()[i];
		VertexShaderPtr vs = _meshVertexShadersMap[&mesh];

		ID3D11InputLayoutPtr inputLayout;

		if (_meshInputLayouts.find(&mesh) == _meshInputLayouts.end())
		{
			DXCall(_device->CreateInputLayout(mesh.InputElements(), mesh.NumInputElements(),
				vs->ByteCode->GetBufferPointer(), vs->ByteCode->GetBufferSize(), &inputLayout));
			_meshInputLayouts.insert(std::make_pair(&mesh, inputLayout));
		}

		if (_meshDepthInputLayouts.find(&mesh) == _meshDepthInputLayouts.end())
		{
			DXCall(_device->CreateInputLayout(mesh.InputElements(), mesh.NumInputElements(),
				_meshDepthVS->ByteCode->GetBufferPointer(), _meshDepthVS->ByteCode->GetBufferSize(), &inputLayout));
			_meshDepthInputLayouts.insert(std::make_pair(&mesh, inputLayout));
		}
    }
}
开发者ID:bxs3514,项目名称:Realtime_GI,代码行数:25,代码来源:MeshRenderer.cpp

示例5: JBKRender_CreateVertexShader

JBKVertexShader* JBKRender_CreateVertexShader(void* blob, int32_t sizeInBytes, JBKShaderInputElement* elements, uint32_t elementCount) {
	JBKVertexShader* shader = &g_vertexShaders[g_vertexShaderCount++];

	D3D11_INPUT_ELEMENT_DESC inputElementArray[16];
	convertInputElements(inputElementArray, elements, elementCount);
	DXCall(g_device->lpVtbl->CreateVertexShader(g_device, blob, sizeInBytes, NULL, &shader->m_shader));
	DXCall(g_device->lpVtbl->CreateInputLayout(g_device, inputElementArray, elementCount, blob, sizeInBytes, &shader->m_inputLayout));

	return shader;
}
开发者ID:ReddogStone,项目名称:jabaku-c,代码行数:10,代码来源:renderapid3d11.c

示例6: JBKRender_DrawDebugText

void JBKRender_DrawDebugText(float x, float y, const char* text, uint32_t color) {
    RECT r;
    r.left = (LONG)x;
    r.top = (LONG)y;
    r.right = r.left;
    r.bottom = r.top;

	DXCall( IDirect3DDevice9_BeginScene(gDevice) );
	gDebugFont->lpVtbl->DrawTextA(gDebugFont, 0, text, -1, &r, DT_LEFT | DT_TOP | DT_NOCLIP, color);
	DXCall( IDirect3DDevice9_EndScene(gDevice) );
}
开发者ID:ReddogStone,项目名称:jabaku-c,代码行数:11,代码来源:renderapid3d9.c

示例7: JBKRender_DrawUserPrimitives

void JBKRender_DrawUserPrimitives(void* data, JBKVertexDataType datatype, JBKPrimitiveType primitivetype, uint32_t primitivecount) {
	int32_t stride = 0;
	DWORD fvf = DataTypeToFVF(datatype, &stride);
	D3DPRIMITIVETYPE d3dprimtype = PrimitiveTypeToD3D(primitivetype);

	SetupTextureStageStates(fvf);

	DXCall( IDirect3DDevice9_SetFVF(gDevice, fvf) );
	DXCall( IDirect3DDevice9_BeginScene(gDevice) );
	DXCall( IDirect3DDevice9_DrawPrimitiveUP(gDevice, d3dprimtype, primitivecount, data, stride) );
	DXCall( IDirect3DDevice9_EndScene(gDevice) );
}
开发者ID:ReddogStone,项目名称:jabaku-c,代码行数:12,代码来源:renderapid3d9.c

示例8: DXCall

ID3DXMesh* Mesh::GenerateNormals(ID3DXMesh* mesh, IDirect3DDevice9* d3d9Device)
{
    // see if we have texture coordinates
    D3DVERTEXELEMENT9 decl[MAX_FVF_DECL_SIZE];
    DXCall(mesh->GetDeclaration(decl));
    bool foundTexCoord = false;
    for (UINT i = 0; i < MAX_FVF_DECL_SIZE; ++i)
    {
        if (decl[i].Stream == 0xFF)
            break;
        else if(decl[i].Usage == D3DDECLUSAGE_TEXCOORD && decl[i].UsageIndex == 0)
        {
            foundTexCoord = true;
            break;
        }
    }

    // Clone the mesh with a new declaration
    D3DVERTEXELEMENT9 tcDecl[] =
    {
        { 0, 0,  D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
        { 0, 12, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,   0 },
        { 0, 24, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
        D3DDECL_END()
    };

    D3DVERTEXELEMENT9 noTCDecl[] =
    {
        { 0, 0,  D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_POSITION, 0 },
        { 0, 12, D3DDECLTYPE_FLOAT3,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_NORMAL,   0 },
        { 0, 24, D3DDECLTYPE_FLOAT2,   D3DDECLMETHOD_DEFAULT, D3DDECLUSAGE_TEXCOORD, 0 },
        D3DDECL_END()
    };

    D3DVERTEXELEMENT9* newDecl;
    if (foundTexCoord)
        newDecl = tcDecl;
    else
        newDecl = noTCDecl;

    ID3DXMesh* clonedMesh = NULL;

    UINT options = D3DXMESH_MANAGED;
    if (indexType == Index32Bit)
        options |= D3DXMESH_32BIT;
    DXCall(mesh->CloneMesh(options, newDecl, d3d9Device, &clonedMesh));
    mesh->Release();

    // Generate the normals
    DXCall(D3DXComputeNormals(clonedMesh, &adjacency[0]));

    return clonedMesh;
}
开发者ID:TheRealMJP,项目名称:SamplePattern,代码行数:53,代码来源:Model.cpp

示例9: SaveTextureAsDDS

void SaveTextureAsDDS(ID3D11Resource* texture, const wchar* filePath)
{
    ID3D11DevicePtr device;
    texture->GetDevice(&device);

    ID3D11DeviceContextPtr context;
    device->GetImmediateContext(&context);

    ScratchImage scratchImage;
    DXCall(CaptureTexture(device, context, texture, scratchImage));
    DXCall(SaveToDDSFile(scratchImage.GetImages(), scratchImage.GetImageCount(),
                         scratchImage.GetMetadata(), DDS_FLAGS_FORCE_DX10_EXT, filePath));
}
开发者ID:TheRealMJP,项目名称:LowResRendering,代码行数:13,代码来源:Textures.cpp

示例10: TempRenderTarget

TempRenderTarget* PostProcessorBase::GetTempRenderTarget(uint32 width, uint32 height, DXGI_FORMAT format,
                                                         uint32 msCount, uint32 msQuality, uint32 mipLevels,
                                                         bool generateMipMaps, bool useAsUAV)
{
    // Look through existing render targets
    for (size_t i = 0; i < tempRenderTargets.size(); ++i)
    {
        TempRenderTarget* rt = tempRenderTargets[i];
        if (!rt->InUse && rt->Width == width && rt->Height == height && rt->Format == format
                && rt->MSCount == msCount && rt->MSQuality == msQuality && (rt->UAView != nullptr) == useAsUAV)
        {
            rt->InUse = true;
            return rt;
        }
    }

    // Didn't find one, have to make one
    TempRenderTarget* rt = new TempRenderTarget();
    D3D11_TEXTURE2D_DESC desc;
    desc.Width = width;
    desc.Height = height;
    desc.ArraySize = 1;
    desc.BindFlags = D3D11_BIND_SHADER_RESOURCE|D3D11_BIND_RENDER_TARGET;
    if(useAsUAV)
        desc.BindFlags |= D3D11_BIND_UNORDERED_ACCESS;
    desc.CPUAccessFlags = 0;
    desc.Format = format;
    desc.MipLevels = mipLevels;
    desc.MiscFlags = generateMipMaps ? D3D11_RESOURCE_MISC_GENERATE_MIPS : 0;
    desc.SampleDesc.Count = msCount;
    desc.SampleDesc.Quality = msQuality;
    desc.Usage = D3D11_USAGE_DEFAULT;
    DXCall(device->CreateTexture2D(&desc, nullptr, &rt->Texture));
    DXCall(device->CreateRenderTargetView(rt->Texture, nullptr, &rt->RTView));
    DXCall(device->CreateShaderResourceView(rt->Texture, nullptr, &rt->SRView));

    if(useAsUAV)
        device->CreateUnorderedAccessView(rt->Texture, nullptr, &rt->UAView);
    else
        rt->UAView = nullptr;

    rt->Width = width;
    rt->Height = height;
    rt->MSCount = msCount;
    rt->MSQuality = msQuality;
    rt->Format = format;
    rt->InUse = true;
    tempRenderTargets.push_back(rt);

    return tempRenderTargets[tempRenderTargets.size() - 1];
}
开发者ID:horzelski,项目名称:MSAAFilter,代码行数:51,代码来源:PostProcessorBase.cpp

示例11: DXCall

    void Effect::ExtractGlobalVars(D3DX11_EFFECT_DESC& effectDesc) {
        for(U32 i = 0; i < effectDesc.GlobalVariables; ++i) {
            ID3DX11EffectVariable* pVar = dx11Effect->GetVariableByIndex(i);

            D3DX11_EFFECT_VARIABLE_DESC varDesc;
            DXCall(pVar->GetDesc(&varDesc));

            ID3DX11EffectType* pType = pVar->GetType();
            D3DX11_EFFECT_TYPE_DESC typeDesc;
            DXCall(pType->GetDesc(&typeDesc));

            AddVariable(pVar, &varDesc, &typeDesc);
        }
    }
开发者ID:panmar,项目名称:pg2,代码行数:14,代码来源:Effect.cpp

示例12: Assert_

void SwapChain::Reset()
{
    Assert_(swapChain);
    if(output == nullptr)
        fullScreen = false;

    // Release all references
    for(uint64 i = 0; i < NumBackBuffers; ++i)
    {
        DX12::Release(backBuffers[i].Texture.Resource);
        DX12::RTVDescriptorHeap.FreePersistent(backBuffers[i].RTV);
    }

    if(format == DXGI_FORMAT_R8G8B8A8_UNORM_SRGB)
        noSRGBFormat = DXGI_FORMAT_R8G8B8A8_UNORM;
    else if(format == DXGI_FORMAT_B8G8R8A8_UNORM_SRGB)
        noSRGBFormat = DXGI_FORMAT_B8G8R8A8_UNORM;
    else
        noSRGBFormat = format;

    if(fullScreen)
        PrepareFullScreenSettings();
    else
    {
        refreshRate.Numerator = 60;
        refreshRate.Denominator = 1;
    }

    DXCall(swapChain->SetFullscreenState(fullScreen, NULL));

    DXCall(swapChain->ResizeBuffers(NumBackBuffers, width, height, noSRGBFormat,
                                    DXGI_SWAP_CHAIN_FLAG_ALLOW_MODE_SWITCH |
                                    DXGI_SWAP_CHAIN_FLAG_ALLOW_TEARING |
                                    DXGI_SWAP_CHAIN_FLAG_FRAME_LATENCY_WAITABLE_OBJECT));

    if(fullScreen)
    {
        DXGI_MODE_DESC mode;
        mode.Format = noSRGBFormat;
        mode.Width = width;
        mode.Height = height;
        mode.RefreshRate.Numerator = 0;
        mode.RefreshRate.Denominator = 0;
        mode.Scaling = DXGI_MODE_SCALING_UNSPECIFIED;
        mode.ScanlineOrdering = DXGI_MODE_SCANLINE_ORDER_UNSPECIFIED;
        DXCall(swapChain->ResizeTarget(&mode));
    }

    AfterReset();
}
开发者ID:TheRealMJP,项目名称:DeferredTexturing,代码行数:50,代码来源:SwapChain.cpp

示例13: SaveTextureAsPNG

void SaveTextureAsPNG(ID3D11Resource* texture, const wchar* filePath)
{
    ID3D11DevicePtr device;
    texture->GetDevice(&device);

    ID3D11DeviceContextPtr context;
    device->GetImmediateContext(&context);

    ScratchImage scratchImage;
    DXCall(CaptureTexture(device, context, texture, scratchImage));

    DXCall(SaveToWICFile(scratchImage.GetImages(), scratchImage.GetImageCount(), WIC_FLAGS_NONE,
                         GetWICCodec(WIC_CODEC_PNG), filePath));
}
开发者ID:TheRealMJP,项目名称:LowResRendering,代码行数:14,代码来源:Textures.cpp

示例14: Assert_

void StructuredBuffer::Initialize(ID3D11Device* device, uint32 stride, uint32 numElements, bool32 dynamic, bool32 useAsUAV,
                                    bool32 appendConsume, bool32 hiddenCounter, const void* initData)
{
    Size = stride * numElements;
    Stride = stride;
    NumElements = numElements;

    Assert_(appendConsume == false || hiddenCounter == false);

    if(appendConsume || hiddenCounter)
        useAsUAV = true;

    D3D11_BUFFER_DESC bufferDesc;
    bufferDesc.ByteWidth = stride * numElements;
    bufferDesc.Usage = useAsUAV ? D3D11_USAGE_DEFAULT : dynamic ? D3D11_USAGE_DYNAMIC : D3D11_USAGE_IMMUTABLE;
    bufferDesc.BindFlags = D3D11_BIND_SHADER_RESOURCE;
    bufferDesc.BindFlags |= useAsUAV ? D3D11_BIND_UNORDERED_ACCESS : 0;
    bufferDesc.CPUAccessFlags = useAsUAV ? 0 : dynamic ? D3D11_CPU_ACCESS_WRITE : 0;
    bufferDesc.MiscFlags = D3D11_RESOURCE_MISC_BUFFER_STRUCTURED;
    bufferDesc.StructureByteStride = stride;

    D3D11_SUBRESOURCE_DATA subresourceData;
    subresourceData.pSysMem = initData;
    subresourceData.SysMemPitch = 0;
    subresourceData.SysMemSlicePitch = 0;

    DXCall(device->CreateBuffer(&bufferDesc, initData != nullptr ? &subresourceData : nullptr, &Buffer));

    D3D11_SHADER_RESOURCE_VIEW_DESC srvDesc;
    srvDesc.Format = DXGI_FORMAT_UNKNOWN;
    srvDesc.ViewDimension = D3D11_SRV_DIMENSION_BUFFER;
    srvDesc.Buffer.FirstElement = 0;
    srvDesc.Buffer.NumElements = numElements;
    DXCall(device->CreateShaderResourceView(Buffer, &srvDesc, &SRView));

    if(useAsUAV)
    {
        D3D11_UNORDERED_ACCESS_VIEW_DESC uavDesc;
        uavDesc.Format = DXGI_FORMAT_UNKNOWN;
        uavDesc.ViewDimension = D3D11_UAV_DIMENSION_BUFFER;
        uavDesc.Buffer.FirstElement = 0;
        uavDesc.Buffer.Flags = 0;
        uavDesc.Buffer.Flags |= appendConsume ? D3D11_BUFFER_UAV_FLAG_APPEND : 0;
        uavDesc.Buffer.Flags |= hiddenCounter ? D3D11_BUFFER_UAV_FLAG_COUNTER : 0;
        uavDesc.Buffer.NumElements = numElements;
        DXCall(device->CreateUnorderedAccessView(Buffer, &uavDesc, &UAView));
    }
}
开发者ID:bxs3514,项目名称:Realtime_GI,代码行数:48,代码来源:GraphicsTypes.cpp

示例15: _ASSERT

    void Effect::SetParam(const string& name, const I32* data, U32 offset, U32 count) {
        auto it = scalarVars.find(name);
        _ASSERT(it != scalarVars.end());

        ID3DX11EffectScalarVariable* scalarVar = it->second;
        DXCall(scalarVar->SetIntArray(data, offset, count));
    }
开发者ID:panmar,项目名称:pg2,代码行数:7,代码来源:Effect.cpp


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