Exemplo n.º 1
0
    void ShaderCompiler::parseConstantBuffers(ID3D12ShaderReflection* reflect, const D3D12_SHADER_DESC& progDesc, std::weak_ptr<DX12DeviceContext> context)
    {
        for (uint_fast32_t i = 0; i < progDesc.ConstantBuffers; ++i) {
            auto cb = reflect->GetConstantBufferByIndex(i);
            D3D12_SHADER_BUFFER_DESC cbDesc;

            cb->GetDesc(&cbDesc);

            LOGS << "Constant buffer : " << cbDesc.Name;

            auto& cbuffer = context.lock()->CreateConstanBuffer(cbDesc.Name);

            for (uint_fast32_t j = 0; j < cbDesc.Variables; ++j) {
                auto var = cb->GetVariableByIndex(j);
                D3D12_SHADER_VARIABLE_DESC vardesc;

                var->GetDesc(&vardesc);

                auto fmt = boost::format("CB var : %1%, Offset: %2%, Size: %3%") % vardesc.Name % vardesc.StartOffset % vardesc.Size;
                LOGS << boost::str(fmt);

                cbuffer.addVariable(vardesc.Name, vardesc.StartOffset, vardesc.Size);
            }
        }
    }
Exemplo n.º 2
0
void RenderTarget::CreateDepthRenderbuffer()
{
	assert(!GetDesc().allowDepthTexture);
	assert(m_active);
	m_depthRenderBuffer.Reset(new RenderBuffer());
	m_depthRenderBuffer->Bind();
	glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, GetDesc().width, GetDesc().height);
	m_depthRenderBuffer->Attach(GL_DEPTH_ATTACHMENT_EXT);
	m_depthRenderBuffer->Unbind();
}
Exemplo n.º 3
0
void RenderTarget::SetDepthTexture(Texture* t)
{
	assert(GetDesc().allowDepthTexture);
	const bool bound = m_active;
	if (!bound) Bind();
	if (!GetDesc().allowDepthTexture) return;
	GLuint texId = 0;
	if (t) texId = static_cast<TextureGL*>(t)->GetTexture();
	glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texId, 0);
	m_depthTexture.Reset(t);
	if (!bound) Unbind();
}
Exemplo n.º 4
0
	PooledTextureRef ImageBasedLensFlare::Setup(const Ptr<Texture> & brightPassTex)
	{
		auto setupTexRef = TexturePool::Instance().FindFree({ TEXTURE_2D, brightPassTex->GetDesc() });
		auto setupTex = setupTexRef->Get()->Cast<Texture>();

		Global::GetRenderEngine()->GetRenderContext()->ClearRenderTarget(setupTex->GetRenderTargetView(0, 0, 1), 0.0f);

		auto ps = Shader::FindOrCreate<LensFlareSetupPS>();

		Global::GetRenderEngine()->GetRenderContext()->SetBlendState(
			BlendStateTemplate<false, false, true, BLEND_PARAM_ONE, BLEND_PARAM_ONE, BLEND_OP_ADD>::Get());

		int2 texSize = int2(setupTex->GetDesc().width / 2, setupTex->GetDesc().height / 2);
		int2 center = texSize;

		for (int i = 0; i < 3; ++i)
		{
			int2 xy = center - texSize / 2;

			ps->SetSRV("brightPassTex", brightPassTex->GetShaderResourceView());
			ps->SetSampler("linearSampler", SamplerTemplate<>::Get());
			ps->Flush();

			DrawQuad({ setupTex->GetRenderTargetView(0, 0, 1) }, 
				(float)xy.x(), (float)xy.y(), (float)texSize.x(), (float)texSize.y());

			texSize /= 2;
		}

		for (int i = 0; i < 5; ++i)
		{
			int2 xy = center - texSize / 2;

			ps->SetSRV("brightPassTex", brightPassTex->GetShaderResourceView());
			ps->SetSampler("linearSampler", SamplerTemplate<>::Get());
			ps->Flush();

			DrawQuad({ setupTex->GetRenderTargetView(0, 0, 1) }, 
				(float)xy.x(), (float)xy.y(), (float)texSize.x(), (float)texSize.y(),
				1.0f, 1.0f, -1.0f, -1.0f);

			texSize *= 2;
		}

		Global::GetRenderEngine()->GetRenderContext()->SetBlendState(nullptr);

		return setupTexRef;
	}
Exemplo n.º 5
0
void CProfiler::BuildTree(HWND m_hTree,IProfileNode *pNode,HTREEITEM hItem)
{
    if(!pNode)return;

    char szMsg[256];
    GetDesc(szMsg,pNode);

    char szItem[512];
    char *pName = (char*)pNode->GetName();
    if(!pName)return;

    int iSize = strlen(pName);
    strcpy(szItem,pNode->GetName());
    for(int k = 0; k < 32 - iSize; k++)
    {
        strcat(szItem," ");
    }
    strcat(szItem,szMsg);

    HTREEITEM hNow = InsertItem(m_hTree,hItem,szItem);

    TreeView_Expand(m_hTree,hItem,TVE_EXPAND);

    IProfileNode *pChild = pNode->GetChild();
    if(pChild)
    {
        while(pChild)
        {
            BuildTree(m_hTree,pChild,hNow);
            pChild = pChild->GetSibling();
        }
    }
}
Exemplo n.º 6
0
void
FontFace::GetFeatureSettings(nsString& aResult)
{
  mFontFaceSet->FlushUserFontSet();
  GetDesc(eCSSFontDesc_FontFeatureSettings, eCSSProperty_font_feature_settings,
          aResult);
}
Exemplo n.º 7
0
void
FontFace::GetDesc(nsCSSFontDesc aDescID,
                  nsCSSProperty aPropID,
                  nsString& aResult) const
{
  MOZ_ASSERT(aDescID == eCSSFontDesc_UnicodeRange ||
             aPropID != eCSSProperty_UNKNOWN,
             "only pass eCSSProperty_UNKNOWN for eCSSFontDesc_UnicodeRange");

  nsCSSValue value;
  GetDesc(aDescID, value);

  aResult.Truncate();

  // Fill in a default value for missing descriptors.
  if (value.GetUnit() == eCSSUnit_Null) {
    if (aDescID == eCSSFontDesc_UnicodeRange) {
      aResult.AssignLiteral("U+0-10FFFF");
    } else if (aDescID != eCSSFontDesc_Family &&
               aDescID != eCSSFontDesc_Src) {
      aResult.AssignLiteral("normal");
    }
    return;
  }

  if (aDescID == eCSSFontDesc_UnicodeRange) {
    // Since there's no unicode-range property, we can't use
    // nsCSSValue::AppendToString to serialize this descriptor.
    nsStyleUtil::AppendUnicodeRange(value, aResult);
  } else {
    value.AppendToString(aPropID, aResult, nsCSSValue::eNormalized);
  }
}
Exemplo n.º 8
0
	void Transform(
		const Ptr<ShaderResourceView> & src,
		const Ptr<RenderTargetView> & dst,
		const Vector<ColorWriteMask, 4> & colorWriteMask,
		const float4 & srcRect,
		const float4 & dstRect,
		const Ptr<class Sampler> & sampler,
		const Ptr<DepthStencilView> & dsv )
	{
		auto rc = Global::GetRenderEngine()->GetRenderContext();

		std::map<String, String> macros;
		for (int32_t i = 0; i < 4; ++i)
		{
			auto & writeMask = colorWriteMask[i];
			String writeChannel = std::to_string(static_cast<uint32_t>(std::log2(static_cast<uint32_t>(writeMask))));
			macros["COLOR_CHANNEL_" + std::to_string(i)] = writeChannel;
		}

		auto transformPS = Shader::FindOrCreate<TransformPS>(macros);
		transformPS->SetSampler("transformSampler", sampler ? sampler : SamplerTemplate<>::Get());
		transformPS->SetSRV("srcTex", src);
		transformPS->Flush();

		auto srcTex = src->GetResource()->Cast<Texture>();
		float topLeftU = srcRect.x() / static_cast<float>(srcTex->GetDesc().width);
		float topLeftV = srcRect.y() / static_cast<float>(srcTex->GetDesc().height);
		float uvWidth  = srcRect.z() / static_cast<float>(srcTex->GetDesc().width);
		float uvHeight = srcRect.w() / static_cast<float>(srcTex->GetDesc().height);

		if (uvWidth == 0.0f)
			uvWidth = 1.0f;
		if (uvHeight == 0.0f)
			uvHeight = 1.0f;

		DrawQuad({ dst },
			dstRect.x(),
			dstRect.y(),
			dstRect.z(),
			dstRect.w(),
			topLeftU,
			topLeftV,
			uvWidth,
			uvHeight, 
			dsv);
	}
void GetTextureSizeD3D( ID3D11Resource* res, unsigned int* width, unsigned int* height )
{

    DebugAssert( res != 0, "Tried to get size of texture on a null ID3D11Resource (the texture resource bound to graphics card)");

    // This is the most generic solution. you can make it a lot
    // simpler if you know it will always be a 2D texture file
    D3D11_RESOURCE_DIMENSION dim;
    res->GetType( &dim );
    switch(dim)
    {
        case D3D11_RESOURCE_DIMENSION_TEXTURE1D:
            { 
                 auto txt = reinterpret_cast<ID3D11Texture1D*>( res );
                 D3D11_TEXTURE1D_DESC desc;
                 txt->GetDesc( &desc );
                 if ( width ) *width = desc.Width;
                 if ( height ) *height = 1;
            }
            break;
        case D3D11_RESOURCE_DIMENSION_TEXTURE2D:
            {
                 auto txt = reinterpret_cast<ID3D11Texture2D*>( res );
                 D3D11_TEXTURE2D_DESC desc;
                 txt->GetDesc( &desc );
                 if ( width ) *width = desc.Width;
                 if ( height ) *height = desc.Height;
            }
            break;
        case D3D11_RESOURCE_DIMENSION_TEXTURE3D:
            {
                 auto txt = reinterpret_cast<ID3D11Texture3D*>( res );
                 D3D11_TEXTURE3D_DESC desc;
                 txt->GetDesc( &desc );
                 if ( width ) *width = desc.Width;
                 if ( height ) *height = desc.Height;
            }
            break;
        default:
             if ( width ) *width = 0;
             if ( height ) *height = 0;
            break;
    }
}
Exemplo n.º 10
0
void VertexBuffer::BufferData(const size_t size, void *data)
{
	PROFILE_SCOPED()
	assert(m_mapMode == BUFFER_MAP_NONE); //must not be currently mapped
	if (GetDesc().usage == BUFFER_USAGE_DYNAMIC) {
		glBindVertexArray(m_vao);
		glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
		glBufferData(GL_ARRAY_BUFFER, (GLsizeiptr)size, (GLvoid*)data, GL_DYNAMIC_DRAW);
	}
}
Exemplo n.º 11
0
void
FontFace::GetUnicodeRange(nsString& aResult)
{
  mFontFaceSet->FlushUserFontSet();

  // There is no eCSSProperty_unicode_range for us to pass in to GetDesc
  // to get a serialized (possibly defaulted) value, but that function
  // doesn't use the property ID for this descriptor anyway.
  GetDesc(eCSSFontDesc_UnicodeRange, eCSSProperty_UNKNOWN, aResult);
}
Exemplo n.º 12
0
// Appends a label to "label" based on content
void CProt_ref::GetLabel(string* label) const
{
    if (IsSetName() && GetName().size() > 0) {
        *label += *GetName().begin();
    } else if (IsSetDesc()) {
        *label += GetDesc();
    } else if (IsSetDb()) {
        GetDb().front()->GetLabel(label);
    }
}
Exemplo n.º 13
0
///////////////////////////////////////////////////////////////////////
// CChart::Convert
// Create CChart with input record string; Return NULL if invalid
//
BOOL CChart::Convert( const char* pszChartFileRecord )
{
    ASSERT_VALID( this );
    BOOL match, done;
    int field, sidx, slen;

    CString s = CString( pszChartFileRecord );
    slen = s.GetLength();
    done = FALSE;
    sidx = 0;

    for( field=0; done == FALSE; field++ )
    {
	match = FALSE;
	switch( field )
	{
	case 0: /* "a," */
	    if ( s.Left(2) == "a," ) match = TRUE;
	    sidx += 2;
	    break;

	case 1: /* account no. - X, XX, or XXX, */
	    match = SetChartAcct( (s.Mid( sidx )).SpanExcluding(","));
	    sidx += m_ChartAcct.GetLength() + 1;
	    break;

	case 2: /* description - XX...X, or XX...X\n */
	    match = SetDesc( (s.Mid( sidx )).SpanExcluding(",\n") );
	    sidx += GetDesc().GetLength() + 1;
	    if ( sidx-1 >= slen || s[sidx-1] == '\n' ) done = TRUE;
	    break;

	case 3: /* Old account - NULL X XX XXX followed by , or \n */
	    match = SetOldAcct( (s.Mid( sidx )).SpanExcluding(",\n") );
	    sidx += m_OldAcct.GetLength() + 1;
	    if( sidx-1 >= slen || s[sidx-1] == '\n' ) done = TRUE;
	    break;

	case 4: /* Summary Account Flag - NULL\n or s\n */
	    //cerr << "\"" << (s.Mid( sidx )).SpanExcluding("\n") "\"\n";
	    match = SetSummaryAcct( (s.Mid( sidx )).SpanExcluding("\n") );
	    if ( sidx >= slen || s[sidx] == '\n' || s[sidx+1] == '\n' ) done = TRUE;
	    break;

	} // switch
	if( match == FALSE ) {
	    cerr << pszChartFileRecord
		 << "Invalid Chart Record\n";
	    done = TRUE;
	}
    } // for
    return match;
} // function
Exemplo n.º 14
0
void DX11Engine::createSwapChainRenderTargets(IUnknown** ppRTV, IUnknown** ppRTVsRGB, 
    IUnknown** ppDSV, IUnknown* pNativeDevice, IUnknown* pSwapChainIn, 
    size_t length, const char* debugName) const
{
    auto pSwapChain = reinterpret_cast<IDXGISwapChain*>(pSwapChainIn);
    auto pDevice = reinterpret_cast<ID3D11Device*>(pNativeDevice);
        
    HRESULT hr = S_OK;
    std::unique_ptr<ID3D11Texture2D, COMDeleter> pD3D11Texture;
        
    // rtv
    DXGI_SWAP_CHAIN_DESC desc;
    V(pSwapChain->GetDesc(&desc));
    V(pSwapChain->GetBuffer(0, __uuidof(ID3D11Texture2D), ref(pD3D11Texture)));
    STAR_SET_DEBUG_NAME(pD3D11Texture, length, debugName);

    CD3D11_RENDER_TARGET_VIEW_DESC rtvDesc(D3D11_RTV_DIMENSION_TEXTURE2D);

    rtvDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM;
    ID3D11RenderTargetView* pRTV;
    V(pDevice->CreateRenderTargetView(pD3D11Texture.get(), &rtvDesc, &pRTV));
    *ppRTV = pRTV;
    STAR_SET_DEBUG_NAME(pRTV, length, debugName);

    rtvDesc.Format = DXGI_FORMAT_B8G8R8A8_UNORM_SRGB;
    V(pDevice->CreateRenderTargetView(pD3D11Texture.get(), &rtvDesc, &pRTV));
    *ppRTVsRGB = pRTV;
    STAR_SET_DEBUG_STRING(pRTV, (debugName + std::string("_sRGB")));
    
    // dsv
    if(ppDSV) {
        D3D11_TEXTURE2D_DESC descTex2D = {
            desc.BufferDesc.Width,
            desc.BufferDesc.Height,
            1, 1, DXGI_FORMAT_D32_FLOAT,{ 1, 0 },
            D3D11_USAGE_DEFAULT, D3D11_BIND_DEPTH_STENCIL,
            0, 0
        };
        
        
        std::unique_ptr<ID3D11Texture2D, COMDeleter> pDST;
        V(pDevice->CreateTexture2D(&descTex2D, nullptr, ref(pDST)));
        STAR_SET_DEBUG_NAME(pDST, length, debugName);

        D3D11_DEPTH_STENCIL_VIEW_DESC descV = {
            DXGI_FORMAT_D32_FLOAT, D3D11_DSV_DIMENSION_TEXTURE2D, 0,{ 0 }
        };
        ID3D11DepthStencilView* pDSV;
        V(pDevice->CreateDepthStencilView(pDST.get(), &descV, &pDSV));
        *ppDSV = pDSV;
        STAR_SET_DEBUG_NAME(pDSV, length, debugName);
    }
}
Exemplo n.º 15
0
void CChart::Dump( CDumpContext& dc ) const
{
    ASSERT_VALID( this );

    CObject::Dump( dc );

    cerr << "\n"
	<< "Account: " << setw(3) <<  GetChartAcct()
	<< " Description: " << setw(25) << GetDesc()
	<< " Old: " << setw(3) << GetOldAcct()
	<< " Summary: " << m_SummaryAcct << "\n" ;

}
Exemplo n.º 16
0
TError TNlLink::WaitAddress(int timeout_s) {
    struct nl_cache *cache;
    int ret;

    L() << "Wait for autoconf at " << GetDesc() << std::endl;

    ret = rtnl_addr_alloc_cache(GetSock(), &cache);
    if (ret < 0)
        return Nl->Error(ret, "Cannot allocate addr cache");

    do {
        for (auto obj = nl_cache_get_first(cache); obj; obj = nl_cache_get_next(obj)) {
            auto addr = (struct rtnl_addr *)obj;

            if (!rtnl_addr_get_local(addr) ||
                    rtnl_addr_get_ifindex(addr) != GetIndex() ||
                    rtnl_addr_get_family(addr) != AF_INET6 ||
                    rtnl_addr_get_scope(addr) >= RT_SCOPE_LINK ||
                    (rtnl_addr_get_flags(addr) &
                     (IFA_F_TENTATIVE | IFA_F_DEPRECATED)))
                continue;

            L() << "Got " << TNlAddr(rtnl_addr_get_local(addr)).Format()
                << " at " << GetDesc() << std::endl;

            nl_cache_free(cache);
            return TError::Success();
        }

        usleep(1000000);
        ret = nl_cache_refill(GetSock(), cache);
        if (ret < 0)
            return Nl->Error(ret, "Cannot refill address cache");
    } while (--timeout_s > 0);

    nl_cache_free(cache);
    return TError(EError::Unknown, "Network autoconf timeout");
}
Exemplo n.º 17
0
bool
FontFace::GetFamilyName(nsString& aResult)
{
  nsCSSValue value;
  GetDesc(eCSSFontDesc_Family, value);

  if (value.GetUnit() == eCSSUnit_String) {
    nsString familyname;
    value.GetStringValue(familyname);
    aResult.Append(familyname);
  }

  return !aResult.IsEmpty();
}
Exemplo n.º 18
0
void CProfiler::WriteLog(int iTab,IProfileNode *pNode,FILE *fp)
{
    if(!pNode || !fp)return;

    char szMsg[512];
    GetDesc(szMsg,pNode);

    char *pName = (char*)pNode->GetName();
    if(!pName)return;

    int iSize = strlen(pName);
    fprintf(fp,pNode->GetName());
    for(int k = 0; k < 32 - iSize; k++)
    {
        fprintf(fp," ");
    }

    for(int i = 0; i < iTab; i++)fprintf(fp,"    ");
    fprintf(fp,szMsg);
    fprintf(fp,"\r\n");

    //综合统计信息
    std::string strName(pNode->GetName());
    IntegratedStatisticsInfoSet::iterator it = m_integratedInfo.find(strName);
    if( it == m_integratedInfo.end() )
    {
        IntegratedStatisticsInfo info;
        info.m_desc = strName;
        info.m_totalCalls = pNode->GetTotalCalls();
        info.m_totalTime = pNode->GetTotalTime();
        info.m_averageTime = pNode->GetAverageTime();
        m_integratedInfo[strName] = info;
    }
    else
    {
        it->second.m_totalCalls += pNode->GetTotalCalls();
        it->second.m_totalTime += pNode->GetTotalTime();
        it->second.m_averageTime = it->second.m_totalTime / (float)(it->second.m_totalCalls);
    }

    IProfileNode *pChild = pNode->GetChild();
    if(pChild)
    {
        while(pChild)
        {
            WriteLog(iTab + 1,pChild,fp);
            pChild = pChild->GetSibling();
        }
    }
}
Exemplo n.º 19
0
int HostIO_CyUSB::OpenEx(CameraID cID)
{
	int		numDevs;
	USHORT	VID;
	USHORT	PID;
	bool	bFoundDevice = false;

	m_log->Write(2, _T("OpenEx name: %s"), cID.SerialToOpen.c_str());
	
	numDevs = cyusb_open();

	for (int i = 0; i < (int)numDevs; i++) 
	{
		h = cyusb_gethandle(i);
		VID = cyusb_getvendor(h);
		PID = cyusb_getproduct(h);

		std::string SerialNum = std::string("None");
		GetSerialNumber(SerialNum);
		std::string SerialToOpen = SerialNum;
		
		std::string Desc = std::string("None");
		GetDesc(Desc);

		m_log->Write(2, _T("Dev %d:"), i);
		m_log->Write(2, _T(" SerialNumber=%s"), SerialNum.c_str());
		m_log->Write(2, _T(" Description=%s"), Desc.c_str());

		if (VID == QSICyVID && PID == QSICyPID && SerialNum == cID.SerialToOpen )
		{
			m_log->Write(2, _T("USB Open found QSI Cy device at index: %d, Serial: %s, Description: %s"), 
							i, SerialNum.c_str(), Desc.c_str());
			bFoundDevice = true;
			break;
		}
	}
	
	if (bFoundDevice && cyusb_kernel_driver_active(h, 0) == 0 && cyusb_claim_interface(h, 0) == 0)
	{
		SetTimeouts(READ_TIMEOUT, WRITE_TIMEOUT);		
	}
	else
	{
		m_log->Write(2, "No devices matched");
	}

	m_log->Write(2, _T("OpenEx Done."));

	return bFoundDevice ? ALL_OK : ERR_USB_OpenFailed;
}
Exemplo n.º 20
0
Uint8 *VertexBuffer::MapInternal(BufferMapMode mode, size_t length)
{
	assert(mode != BUFFER_MAP_NONE); //makes no sense
	assert(m_mapMode == BUFFER_MAP_NONE); //must not be currently mapped
	m_mapMode = mode;
	if (GetDesc().usage == BUFFER_USAGE_STATIC) {
		glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
		if (mode == BUFFER_MAP_READ)
			return reinterpret_cast<Uint8*>(glMapBuffer(GL_ARRAY_BUFFER, GL_READ_ONLY));
		else if (mode == BUFFER_MAP_WRITE)
			return reinterpret_cast<Uint8*>(glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY));
	}

	return m_data;
}
Exemplo n.º 21
0
static void ReflectShaderConstantBuffer(
    ID3D12ShaderReflection*             reflection,
    ShaderReflectionDescriptor&         reflectionDesc,
    const D3D12_SHADER_DESC&            shaderDesc,
    const D3D12_SHADER_INPUT_BIND_DESC& inputBindDesc,
    long                                stageFlags,
    UINT&                               cbufferIdx)
{
    /* Initialize resource view descriptor for constant buffer */
    auto resourceView = FetchOrInsertResource(reflectionDesc, inputBindDesc.Name, ResourceType::Buffer, inputBindDesc.BindPoint);
    {
        resourceView->bindFlags     |= BindFlags::ConstantBuffer;
        resourceView->stageFlags    |= stageFlags;
        resourceView->arraySize     = inputBindDesc.BindCount;
    }

    /* Determine constant buffer size */
    if (cbufferIdx < shaderDesc.ConstantBuffers)
    {
        auto cbufferReflection = reflection->GetConstantBufferByIndex(cbufferIdx++);

        D3D12_SHADER_BUFFER_DESC shaderBufferDesc;
        auto hr = cbufferReflection->GetDesc(&shaderBufferDesc);
        DXThrowIfFailed(hr, "failed to retrieve D3D12 shader buffer descriptor");

        if (shaderBufferDesc.Type == D3D_CT_CBUFFER)
        {
            /* Store constant buffer size in output descriptor */
            resourceView->constantBufferSize = shaderBufferDesc.Size;
        }
        else
        {
            /* Type mismatch in descriptors */
            throw std::runtime_error(
                "failed to match D3D12 shader buffer descriptor \"" + std::string(shaderBufferDesc.Name) +
                "\" with input binding descriptor for constant buffer \"" + std::string(inputBindDesc.Name) + "\""
            );
        }
    }
    else
    {
        /* Resource index mismatch in descriptor */
        throw std::runtime_error(
            "failed to find D3D12 shader buffer descriptor for input binding descriptor \"" +
            std::string(inputBindDesc.Name) + "\""
        );
    }
}
Exemplo n.º 22
0
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
MStatus CVsSkinnerCmd::redoIt()
{
	if ( m_undo.ArgDatabase().isFlagSet( kOptHelp ) )
	{
		GetSyntaxHelp()->PrintHelp( GetName(), GetDesc() );
		return MS::kSuccess;
	}

	m_undo.SaveCurrentSelection();

	if ( m_undo.ArgDatabase().isFlagSet( kOptCreate ) )
	{
		return DoCreate();
	}
	else if ( m_undo.ArgDatabase().isFlagSet( kOptNewVolume ) )
	{
		MSelectionList optSelectionList;
		m_undo.ArgDatabase().getObjects( optSelectionList );
		MSelectionList volumeList( DoNewVolumes( GetSpecifiedSkinnerNode(), optSelectionList ) );
		if ( volumeList.length() == 0 )
		{
			merr << "Couldn't create new volumes" << std::endl;
			return MS::kFailure;
		}
		MGlobal::setActiveSelectionList( volumeList, MGlobal::kReplaceList );
		MStringArray vA;
		volumeList.getSelectionStrings( vA );
		setResult( vA );

		return MS::kSuccess;
	}
	else if ( m_undo.ArgDatabase().isFlagSet( kOptAttachMesh ) )
	{
		return DoAttachMesh( GetSpecifiedSkinnerNode(), GetSpecifiedMesh() );
	}
	else if ( m_undo.ArgDatabase().isFlagSet( kOptDetachMesh ) )
	{
		return DoDetachMesh( GetSpecifiedSkinnerNode() );
	}
	else if ( m_undo.ArgDatabase().isFlagSet( kOptLs ) )
	{
		return DoLs();
	}

	merr << GetName() << ": No action specified" << std::endl;

	return MS::kFailure;
}
Exemplo n.º 23
0
VertexBuffer::VertexBuffer(const VertexBufferDesc &desc)
{
	m_desc = desc;
	//update offsets in desc
	for (Uint32 i = 0; i < MAX_ATTRIBS; i++) {
		if (m_desc.attrib[i].offset == 0)
			m_desc.attrib[i].offset = VertexBufferDesc::CalculateOffset(m_desc, m_desc.attrib[i].semantic);
	}

	//update stride in desc (respecting offsets)
	if (m_desc.stride == 0)
	{
		Uint32 lastAttrib = 0;
		while (lastAttrib < MAX_ATTRIBS) {
			if (m_desc.attrib[lastAttrib].semantic == ATTRIB_NONE)
				break;
			lastAttrib++;
		}

		m_desc.stride = m_desc.attrib[lastAttrib].offset + VertexBufferDesc::GetAttribSize(m_desc.attrib[lastAttrib].format);
	}
	assert(m_desc.stride > 0);
	assert(m_desc.numVertices > 0);

	SetVertexCount(m_desc.numVertices);

	glGenBuffers(1, &m_buffer);

	//Allocate initial data store
	//Using zeroed m_data is not mandatory, but otherwise contents are undefined
	glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
	const Uint32 dataSize = m_desc.numVertices * m_desc.stride;
	m_data = new Uint8[dataSize];
	memset(m_data, 0, dataSize);
	const GLenum usage = (m_desc.usage == BUFFER_USAGE_STATIC) ? GL_STATIC_DRAW : GL_DYNAMIC_DRAW;
	glBufferData(GL_ARRAY_BUFFER, dataSize, m_data, usage);
	glBindBuffer(GL_ARRAY_BUFFER, 0);

	//Don't keep client data around for static buffers
	if (GetDesc().usage == BUFFER_USAGE_STATIC) {
		delete[] m_data;
		m_data = nullptr;
	}

	//If we had VAOs could set up the pointers already
}
Exemplo n.º 24
0
void VertexBuffer::Unmap()
{
	assert(m_mapMode != BUFFER_MAP_NONE); //not currently mapped

	if (GetDesc().usage == BUFFER_USAGE_STATIC) {
		glUnmapBuffer(GL_ARRAY_BUFFER);
		glBindBuffer(GL_ARRAY_BUFFER, 0);
	} else {
		if (m_mapMode == BUFFER_MAP_WRITE) {
			const GLsizei dataSize = m_desc.numVertices * m_desc.stride;
			glBindBuffer(GL_ARRAY_BUFFER, m_buffer);
			glBufferSubData(GL_ARRAY_BUFFER, 0, dataSize, m_data);
			glBindBuffer(GL_ARRAY_BUFFER, 0);
		}
	}

	m_mapMode = BUFFER_MAP_NONE;
}
Exemplo n.º 25
0
	PooledTextureRef SSR::BuildHZB(const Ptr<Texture> & depthTex)
	{
		auto texDesc = depthTex->GetDesc();
		texDesc.format = RENDER_FORMAT_R16_FLOAT;
		texDesc.bindFlag = TEXTURE_BIND_SHADER_RESOURCE | TEXTURE_BIND_RENDER_TARGET;
		texDesc.mipLevels = 0;

		auto hzb0Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });
		auto hzb1Ref = TexturePool::Instance().FindFree({ TEXTURE_2D, texDesc });

		auto hzb0 = hzb0Ref->Get()->Cast<Texture>();
		auto hzb1 = hzb1Ref->Get()->Cast<Texture>();

		Transform(
			depthTex->GetShaderResourceView(0, 1, 0, 1, false, RENDER_FORMAT_R24_UNORM_X8_TYPELESS), 
			hzb0Ref->Get()->Cast<Texture>()->GetRenderTargetView(0, 0, 1));

		auto rc = Global::GetRenderEngine()->GetRenderContext();

		auto ps = Shader::FindOrCreate<HZBBuildPS>();

		for (int32_t mipLevel = 1; mipLevel < hzb0->GetDesc().mipLevels; ++mipLevel)
		{
			auto & mipSize = hzb0->GetMipSize(mipLevel - 1);
			auto w = mipSize.x();
			auto h = mipSize.y();
			float4 screenSize = float4((float)w, (float)h, 1.0f / (float)w, 1.0f / (float)h);

			ps->SetScalar("screenSize", screenSize);
			ps->SetScalar("mipLevel", (float)(mipLevel - 1));
			ps->SetSRV("depthTex", hzb0->GetShaderResourceView());
			ps->SetSampler("pointSampler", SamplerTemplate<FILTER_MIN_MAG_MIP_POINT>::Get());

			ps->Flush();

			auto & targetMipSize = hzb0->GetMipSize(mipLevel);

			DrawQuad({ hzb1->GetRenderTargetView(mipLevel, 0, 1) });

			hzb1->CopyTo(hzb0, mipLevel, 0, 0, 0, 0, mipLevel, 0);
		}

		return hzb0Ref;
	}
Exemplo n.º 26
0
int HostIO_CyUSB::ListDevices(std::vector<CameraID> & vID )
{
	int		numDevs;
	USHORT	VID;
	USHORT	PID;

	m_log->Write(2, _T("ListDevices started."));
	numDevs = cyusb_open();

	for (int i = 0; i < (int)numDevs; i++) 
	{
		h = cyusb_gethandle(i);
		VID = cyusb_getvendor(h);
		PID = cyusb_getproduct(h);

		std::string SerialNum = std::string("None");
		GetSerialNumber(SerialNum);
		std::string SerialToOpen = SerialNum;
		
		std::string Desc = std::string("None");
		GetDesc(Desc);
		
		m_log->Write(2, _T("Dev %d:"), i);
		m_log->Write(2, _T(" SerialNumber=%s"), SerialNum.c_str());
		m_log->Write(2, _T(" Description=%s"), Desc.c_str());

		if (VID == QSICyVID && PID == QSICyPID && !SerialNum.empty() )
		{
			m_log->Write(2, 
			             _T("USB ListDevices found QSI Cy device at index: %d, Serial: %s, Description: %s"), 
						 i, 
			             SerialNum.c_str(), 
			             Desc.c_str()
			             );
			CameraID id(SerialNum, SerialToOpen, Desc, VID, PID, CameraID::CP_CyUSB);
			vID.push_back(id);
		}
	}
	
	cyusb_close();
	
	m_log->Write(2, _T("USB ListDevices Done. Number of devices found: %d"), numDevs);
	return S_OK;
}
Exemplo n.º 27
0
void CHARACTER::ClearAffect(bool bSave)
{
	TAffectFlag afOld = m_afAffectFlag;
	WORD	wMovSpd = GetPoint(POINT_MOV_SPEED);
	WORD	wAttSpd = GetPoint(POINT_ATT_SPEED);

	itertype(m_list_pkAffect) it = m_list_pkAffect.begin();

	while (it != m_list_pkAffect.end())
	{
		CAffect * pkAff = *it;

		if (bSave)
		{
			if ( IS_NO_CLEAR_ON_DEATH_AFFECT(pkAff->dwType) || IS_NO_SAVE_AFFECT(pkAff->dwType) )
			{
				++it;
				continue;
			}

			if (IsPC())
			{
				SendAffectRemovePacket(GetDesc(), GetPlayerID(), pkAff->dwType, pkAff->bApplyOn);
			}
		}

		ComputeAffect(pkAff, false);

		it = m_list_pkAffect.erase(it);
		CAffect::Release(pkAff);
	}

	if (afOld != m_afAffectFlag ||
			wMovSpd != GetPoint(POINT_MOV_SPEED) ||
			wAttSpd != GetPoint(POINT_ATT_SPEED))
		UpdatePacket();

	CheckMaximumPoints();

	if (m_list_pkAffect.empty())
		event_cancel(&m_pkAffectEvent);
}
Exemplo n.º 28
0
ProxyImplSurface::ProxyImplSurface(IBase *pimpl)
    : ProxyBase<IBase>(pimpl)
{
    D3DSURFACE_DESC desc;
    HRESULT res = GetDesc(&desc);
    assert(SUCCEEDED(res));
    if (SUCCEEDED(res))
    {
        static set<D3DFORMAT> unsupported;
        
        size_t b = bytesPerPixel(desc.Format);
        if (b == 0 && !unsupported.count(desc.Format))
        {
            unsupported.insert(desc.Format);
            char letters[5];
            letters[4] = 0;
            memcpy(letters, &desc.Format, 4);
            LOG("Unsupported surface format: " << desc.Format << ": " << letters);
        }
    }
}
Exemplo n.º 29
0
bool CHARACTER::DragonSoul_RefineWindow_Open(LPENTITY pEntity)
{
	if (NULL == m_pointsInstant.m_pDragonSoulRefineWindowOpener)
	{
		m_pointsInstant.m_pDragonSoulRefineWindowOpener = pEntity;
	}

	TPacketGCDragonSoulRefine PDS;
	PDS.header = HEADER_GC_DRAGON_SOUL_REFINE;
	PDS.bSubType = DS_SUB_HEADER_OPEN;
	LPDESC d = GetDesc();

	if (NULL == d)
	{
		sys_err ("User(%s)'s DESC is NULL POINT.", GetName());
		return false;
	}

	d->Packet(&PDS, sizeof(PDS));
	return true;
}
Exemplo n.º 30
0
void
FontFace::GetFamily(nsString& aResult)
{
  mFontFaceSet->FlushUserFontSet();

  // Serialize the same way as in nsCSSFontFaceStyleDecl::GetPropertyValue.
  nsCSSValue value;
  GetDesc(eCSSFontDesc_Family, value);

  aResult.Truncate();

  if (value.GetUnit() == eCSSUnit_Null) {
    return;
  }

  nsDependentString family(value.GetStringBufferValue());
  if (!family.IsEmpty()) {
    // The string length can be zero when the author passed an invalid
    // family name or an invalid descriptor to the JS FontFace constructor.
    nsStyleUtil::AppendEscapedCSSString(family, aResult);
  }
}