當前位置: 首頁>>代碼示例>>C++>>正文


C++ Assert_函數代碼示例

本文整理匯總了C++中Assert_函數的典型用法代碼示例。如果您正苦於以下問題:C++ Assert_函數的具體用法?C++ Assert_怎麽用?C++ Assert_使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了Assert_函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: ClearFinishedUploads

static void ClearFinishedUploads(uint64 flushCount)
{
    const uint64 start = UploadSubmissionStart;
    const uint64 used = UploadSubmissionUsed;
    for(uint64 i = 0; i < used; ++i)
    {
        const uint64 idx = (start + i) % MaxUploadSubmissions;
        UploadSubmission& submission = UploadSubmissions[idx];
        Assert_(submission.Size > 0);
        Assert_(submission.FenceValue != uint64(-1));
        Assert_(UploadBufferUsed >= submission.Size);

        if(i < flushCount)
            UploadFence.Wait(submission.FenceValue);

        if(UploadFence.Signaled(submission.FenceValue))
        {
            UploadSubmissionStart = (UploadSubmissionStart + 1) % MaxUploadSubmissions;
            UploadSubmissionUsed -= 1;
            UploadBufferStart = (UploadBufferStart + submission.Padding) % UploadBufferSize;
            Assert_(submission.Offset == UploadBufferStart);
            Assert_(UploadBufferStart + submission.Size <= UploadBufferSize);
            UploadBufferStart = (UploadBufferStart + submission.Size) % UploadBufferSize;
            UploadBufferUsed -= (submission.Size + submission.Padding);
            submission.Reset();

            if(UploadBufferUsed == 0)
                UploadBufferStart = 0;
        }
    }
}
開發者ID:megaes,項目名稱:DeferredTexturing,代碼行數:31,代碼來源:DX12_Upload.cpp

示例2: GetBoundCornersFromPoints

void GetBoundCornersFromPoints(const XMFLOAT3* points, uint32 numPoints, uint32 stride, 
	XMVECTOR &minx, XMVECTOR &maxx, XMVECTOR &miny, XMVECTOR &maxy, XMVECTOR &minz, XMVECTOR &maxz)
{
	Assert_(numPoints > 0);
	Assert_(points);

	minx = maxx = miny = maxy = minz = maxz = XMLoadFloat3(points);

	for (uint32 i = 1; i < numPoints; i++)
	{
		XMVECTOR Point = XMLoadFloat3((XMFLOAT3*)((BYTE*)points + i * stride));

		float px = XMVectorGetX(Point);
		float py = XMVectorGetY(Point);
		float pz = XMVectorGetZ(Point);

		if (px < XMVectorGetX(minx))
			minx = Point;

		if (px > XMVectorGetX(maxx))
			maxx = Point;

		if (py < XMVectorGetY(miny))
			miny = Point;

		if (py > XMVectorGetY(maxy))
			maxy = Point;

		if (pz < XMVectorGetZ(minz))
			minz = Point;

		if (pz > XMVectorGetZ(maxz))
			maxz = Point;
	}
}
開發者ID:bxs3514,項目名稱:Realtime_GI,代碼行數:35,代碼來源:BoundUtils.cpp

示例3: AverageSpectrumSamples

float AverageSpectrumSamples(const float *lambda, const float *vals, int n,
                             float lambdaStart, float lambdaEnd) {
    for (int i = 0; i < n - 1; ++i) Assert_(lambda[i + 1] > lambda[i]);
    Assert_(lambdaStart < lambdaEnd);
    // Handle cases with out-of-bounds range or single sample only
    if (lambdaEnd <= lambda[0]) return vals[0];
    if (lambdaStart >= lambda[n - 1]) return vals[n - 1];
    if (n == 1) return vals[0];
    float sum = 0;
    // Add contributions of constant segments before/after samples
    if (lambdaStart < lambda[0]) sum += vals[0] * (lambda[0] - lambdaStart);
    if (lambdaEnd > lambda[n - 1])
        sum += vals[n - 1] * (lambdaEnd - lambda[n - 1]);

    // Advance to first relevant wavelength segment
    int i = 0;
    while (lambdaStart > lambda[i + 1]) ++i;
    Assert_(i + 1 < n);

    // Loop over wavelength sample segments and add contributions
    auto interp = [lambda, vals](float w, int i) {
        return SpectrumLerp((w - lambda[i]) / (lambda[i + 1] - lambda[i]), vals[i],
                    vals[i + 1]);
    };
    for (; i + 1 < n && lambdaEnd >= lambda[i]; ++i) {
        float segLambdaStart = std::max(lambdaStart, lambda[i]);
        float segLambdaEnd = std::min(lambdaEnd, lambda[i + 1]);
        sum += 0.5f * (interp(segLambdaStart, i) + interp(segLambdaEnd, i)) *
               (segLambdaEnd - segLambdaStart);
    }
    return sum / (lambdaEnd - lambdaStart);
}
開發者ID:TheRealMJP,項目名稱:LowResRendering,代碼行數:32,代碼來源:Spectrum.cpp

示例4: Assert_

SceneObject *Scene::addDynamicOpaqueBoxObject(float scale, const Float3 &pos, const Quaternion &rot)
{
	Assert_(_numObjectBases < MAX_DYNAMIC_OBJECTS);
	Assert_(_numTotalModelsShared < MAX_MODELS);
	Assert_(_numObjectBases < MAX_OBJECT_MATRICES);
	Assert_(_numPrevWVPs < MAX_OBJECT_MATRICES);

	if (!_boxModel)
	{
		addBoxModel();
		_modelIndices.push_back(_numTotalModelsShared - 1);
	}

	uint64 modelIndex = getModelIndex(_boxModel);
	Assert_(modelIndex != -1);

	_objectBases[_numObjectBases] = createBase(scale, pos, rot);
	_prevWVPs[_numPrevWVPs] = _objectBases[_numObjectBases];
	_sceneStaticOpaqueObjectBounds[_numStaticOpaqueObjects] = SceneObjectBound();

	SceneObject &obj = _dynamicOpaqueObjects[_numDynamicOpaqueObjects];
	obj.base = &_objectBases[_numObjectBases];
	obj.model = _boxModel;
	obj.bound = &_sceneDynamicOpaqueObjectBounds[_numDynamicOpaqueObjects];
	obj.prevWVP = &_prevWVPs[_numPrevWVPs];
	obj.id = _highestSceneObjId++;

	genSceneObjectBounds(DYNAMIC_OBJ | OPAQUE_OBJ, _numDynamicOpaqueObjects, modelIndex);

	_numObjectBases++;
	_numPrevWVPs++;
	_numDynamicOpaqueObjects++;

	return &obj;
}
開發者ID:bxs3514,項目名稱:Realtime_GI,代碼行數:35,代碼來源:Scene.cpp

示例5: 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

示例6: TempRawBuffer

TempBuffer TempRawBuffer(uint64 numElements, bool makeDescriptor)
{
    Assert_(numElements > 0);
    const uint64 stride = 4;

    MapResult tempMem = DX12::AcquireTempBufferMem(numElements * stride, stride);
    Assert_(tempMem.ResourceOffset % stride == 0);

    TempBuffer result;
    result.CPUAddress = tempMem.CPUAddress;

    if(makeDescriptor)
    {
        TempDescriptorAlloc srvAlloc = SRVDescriptorHeap.AllocateTemporary(1);

        D3D12_SHADER_RESOURCE_VIEW_DESC srvDesc = { };
        srvDesc.Format = DXGI_FORMAT_R32_TYPELESS;
        srvDesc.ViewDimension = D3D12_SRV_DIMENSION_BUFFER;
        srvDesc.Shader4ComponentMapping = D3D12_DEFAULT_SHADER_4_COMPONENT_MAPPING;
        srvDesc.Buffer.FirstElement = uint32(tempMem.ResourceOffset / stride);
        srvDesc.Buffer.Flags = D3D12_BUFFER_SRV_FLAG_RAW;
        srvDesc.Buffer.NumElements = uint32(numElements);
        DX12::Device->CreateShaderResourceView(tempMem.Resource, &srvDesc, srvAlloc.StartCPUHandle);

        result.DescriptorIndex = srvAlloc.StartIndex;
    }

    return result;
}
開發者ID:TheRealMJP,項目名稱:DeferredTexturing,代碼行數:29,代碼來源:DX12_Helpers.cpp

示例7: Assert_

void File::Open(const wchar* filePath, OpenMode openMode_)
{
    Assert_(fileHandle == INVALID_HANDLE_VALUE);
    openMode = openMode_;

    if(openMode == OpenRead)
    {
        Assert_(FileExists(filePath));

        // Open the file
        fileHandle = CreateFile(filePath, GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
        if(fileHandle == INVALID_HANDLE_VALUE)
            Win32Call(false);
    }
    else
    {
        // If the exists, delete it
        if(FileExists(filePath))
            Win32Call(DeleteFile(filePath));

        // Create the file
        fileHandle = CreateFile(filePath, GENERIC_WRITE, 0, NULL, CREATE_NEW, FILE_ATTRIBUTE_NORMAL, NULL);
        if(fileHandle == INVALID_HANDLE_VALUE)
            Win32Call(false);
    }
}
開發者ID:MehdiNS,項目名稱:Shadows,代碼行數:26,代碼來源:FileIO.cpp

示例8: 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

示例9: Assert_

void PostProcessHelper::End()
{
    Assert_(cmdList != nullptr);
    cmdList = nullptr;

    for(uint64 i = 0; i < tempRenderTargets.Count(); ++i)
        Assert_(tempRenderTargets[i]->InUse == false);
}
開發者ID:TheRealMJP,項目名稱:DeferredTexturing,代碼行數:8,代碼來源:PostProcessHelper.cpp

示例10: InterpolateSpectrumSamples

float InterpolateSpectrumSamples(const float *lambda, const float *vals, int n,
                                 float l) {
    for (int i = 0; i < n - 1; ++i) Assert_(lambda[i + 1] > lambda[i]);
    if (l <= lambda[0]) return vals[0];
    if (l >= lambda[n - 1]) return vals[n - 1];
    int offset = FindInterval(n, [&](int index) { return l >= lambda[index]; });
    Assert_(l >= lambda[offset] && l <= lambda[offset + 1]);
    float t = (l - lambda[offset]) / (lambda[offset + 1] - lambda[offset]);
    return SpectrumLerp(t, vals[offset], vals[offset + 1]);
}
開發者ID:TheRealMJP,項目名稱:LowResRendering,代碼行數:10,代碼來源:Spectrum.cpp

示例11: Assert_

void SettingsContainer::AddOrientationSetting(const char* name, const char* label, const char* group,
                                              Quaternion initialVal, const char* helpText)
{
    Assert_(settings.find(name) == settings.end());
    Assert_(tweakBar != nullptr);
    OrientationSetting* setting = new OrientationSetting();
    setting->Initialize(tweakBar, name, group, label, helpText, initialVal);
    settings[name] = setting;
    allocatedSettings.push_back(setting);
}
開發者ID:MehdiNS,項目名稱:Shadows,代碼行數:10,代碼來源:Settings.cpp

示例12: AllocUploadSubmission

static bool AllocUploadSubmission(uint64 size)
{
    Assert_(UploadSubmissionUsed <= MaxUploadSubmissions);
    if(UploadSubmissionUsed == MaxUploadSubmissions)
        return false;

    const uint64 submissionIdx = (UploadSubmissionStart + UploadSubmissionUsed) % MaxUploadSubmissions;
    Assert_(UploadSubmissions[submissionIdx].Size == 0);

    Assert_(UploadBufferUsed <= UploadBufferSize);
    if(size > (UploadBufferSize - UploadBufferUsed))
        return false;

    const uint64 start = UploadBufferStart;
    const uint64 end = UploadBufferStart + UploadBufferUsed;
    uint64 allocOffset = uint64(-1);
    uint64 padding = 0;
    if(end < UploadBufferSize)
    {
        const uint64 endAmt = UploadBufferSize - end;
        if(endAmt >= size)
        {
            allocOffset = end;
        }
        else if(start >= size)
        {
            // Wrap around to the beginning
            allocOffset = 0;
            UploadBufferUsed += endAmt;
            padding = endAmt;
        }
    }
    else
    {
        const uint64 wrappedEnd = end % UploadBufferSize;
        if((start - wrappedEnd) >= size)
            allocOffset = wrappedEnd;
    }

    if(allocOffset == uint64(-1))
        return false;

    UploadSubmissionUsed += 1;
    UploadBufferUsed += size;

    ++UploadFenceValue;

    UploadSubmissions[submissionIdx].Offset = allocOffset;
    UploadSubmissions[submissionIdx].Size = size;
    UploadSubmissions[submissionIdx].FenceValue = UploadFenceValue;
    UploadSubmissions[submissionIdx].Padding = padding;

    return true;
}
開發者ID:megaes,項目名稱:DeferredTexturing,代碼行數:54,代碼來源:DX12_Upload.cpp

示例13: TempDescriptorTable

D3D12_GPU_DESCRIPTOR_HANDLE TempDescriptorTable(const D3D12_CPU_DESCRIPTOR_HANDLE* handles, uint64 count)
{
    Assert_(count <= MaxBindCount);
    Assert_(count > 0);

    TempDescriptorAlloc tempAlloc = SRVDescriptorHeap.AllocateTemporary(uint32(count));

    uint32 destRanges[1] = { uint32(count) };
    Device->CopyDescriptors(1, &tempAlloc.StartCPUHandle, destRanges, uint32(count), handles, DescriptorCopyRanges, SRVDescriptorHeap.HeapType);

    return tempAlloc.StartGPUHandle;
}
開發者ID:TheRealMJP,項目名稱:DeferredTexturing,代碼行數:12,代碼來源:DX12_Helpers.cpp

示例14: Assert_

void SettingsContainer::AddFloatSetting(const char* name, const char* label, const char* group,
                                        float initialVal, float minVal, float maxVal, float step,
                                        const char* helpText)
{
    Assert_(settings.find(name) == settings.end());
    Assert_(tweakBar != nullptr);
    FloatSetting* setting = new FloatSetting();
    setting->Initialize(tweakBar, name, group, label, helpText, initialVal, minVal, maxVal, step,
                        ConversionMode::None, 1.0f);
    settings[name] = setting;
    allocatedSettings.push_back(setting);
}
開發者ID:horzelski,項目名稱:MSAAFilter,代碼行數:12,代碼來源:Settings.cpp

示例15: Assert_

// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
//		¥ Test
// ÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑÑ
bool CBitArray::Test(
	TBitIndex		inBit)
{
	Assert_(inBit<mMax);

	return ((mBitArray[(inBit/32)] & (1 << (inBit%32))) !=0);
}
開發者ID:MaddTheSane,項目名稱:tntbasic,代碼行數:10,代碼來源:CBitArray.cpp


注:本文中的Assert_函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。