Ejemplo n.º 1
0
/*!
************************************************************************
* \brief
*    Read one picture from explicit sequence information file
************************************************************************
*/
void ReadExplicitSeqFile(ExpSeqInfo *seq_info, FILE *expSFile, int coding_index)
{
	int  frm_header = ReadTextField(expSFile, "Frame");

	if (frm_header != -1)
	{
		ReadFrameData (expSFile, seq_info, coding_index);
	}
	else
	{
		printf("ReadExplicitSeqFile : No more data. \n");
		report_stats_on_error();
	}
}
Ejemplo n.º 2
0
	void ChoiceForm::Autotune(float timeBudget)
	{
		bool countOnly = false;
		ResetButton_Clicked(nullptr);
		referenceFrame = ReadFrameData(choiceControl->RenderFrame());
		EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue> currentChoices;
		currentBestValue = 1e30f;
		currentBestChoices = currentChoices;
		HashSet<String> selectedChoices;
		for (auto & chk : choiceCheckBoxes)
			if (chk.Value->Checked)
				selectedChoices.Add(chk.Key);
		autotuningLog.Clear();
		auto startTimePoint = PerformanceCounter::Start();
		int count = AutotuneHelper(selectedChoices, currentChoices, timeBudget, countOnly);
		float time = PerformanceCounter::EndSeconds(startTimePoint);
		autotuningLog << L"time: " << time << EndLine;
		printf("variant count: %d\ntime: %f\n", count, time);
		File::WriteAllText(L"autotuneLog.txt", autotuningLog.ToString());
		if (!countOnly)
		{
			existingChoices = currentBestChoices;
			disableChoiceChangeCapture = true;
			for (auto & choice : existingChoices)
			{
				auto cmb = choiceComboBoxes[choice.Key].GetValue();
				int idxToSelect = 0;
				for (int i = 0; i < cmb->Items.Count(); i++)
					if (cmb->GetTextItem(i)->GetText() == choice.Value.ToString())
					{
						idxToSelect = i;
						break;
					}
				cmb->SetSelectedIndex(idxToSelect);
			}
			disableChoiceChangeCapture = false;
			Recompile();
			ShaderChanged(currentShaderName);
		}
			
	}
Ejemplo n.º 3
0
	int ChoiceForm::AutotuneHelper(HashSet<String> & selectedChoices, EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue>& currentChoices, float timeBudget, bool countOnly)
	{
		auto choices = choiceControl->GetChoices(currentShaderName, currentChoices);
		List<Spire::Compiler::ShaderChoice> filteredChoices;
		for (auto & choice : choices)
			if (!currentChoices.ContainsKey(choice.ChoiceName))
				filteredChoices.Add(choice);
		choices = _Move(filteredChoices);
		// find first non-trivial choice
		Spire::Compiler::ShaderChoice * currentChoice = nullptr;
		for (auto & choice : choices)
		{
			if (choice.Options.Count() > 1 && selectedChoices.Contains(choice.ChoiceName))
			{
				currentChoice = &choice;
				break;
			}
		}
		if (currentChoice)
		{
			int count = 0;
			for (auto & opt : currentChoice->Options)
			{
				EnumerableDictionary<String, Spire::Compiler::ShaderChoiceValue> newChoices = currentChoices;
				newChoices[currentChoice->ChoiceName] = opt;
				count += AutotuneHelper(selectedChoices, newChoices, timeBudget, countOnly);
			}
			return count;
		}
		else
		{
			if (!countOnly)
			{
				printf("Testing shader variant...");
				// compile and evaluate
				auto schedule = GenerateSchedule(currentChoices, EnumerableDictionary<String, EnumerableDictionary<String, String>>());
				choiceControl->RecompileShader(currentShaderName, schedule);
				// render 1000 frames and measure time
				float minTime = 1e30f;
				for (int f = 0; f < 20; f++)
				{
					glFinish();
					auto timeP = CoreLib::Diagnostics::PerformanceCounter::Start();
					for (int i = 0; i < 10; i++)
					{
						choiceControl->RenderFrame();
					}
					glFinish();

					auto time = (float)CoreLib::Diagnostics::PerformanceCounter::ToSeconds(CoreLib::Diagnostics::PerformanceCounter::End(timeP)) * 100.0f;
					if (time < minTime)
						minTime = time;
				}


				choiceControl->UpdateWindow();
				auto frameData = ReadFrameData(choiceControl->RenderFrame());
				float error = MeasureError(referenceFrame, frameData);
				float value = 0;
				if (minTime < timeBudget)
					value = error;
				else
					value = 20.0f + minTime;
				if (value < currentBestValue)
				{
					currentBestValue = value;
					currentBestChoices = currentChoices;
				}
				autotuningLog << minTime << L"," << error<<EndLine;
				printf("%f ms, error: %f\n", minTime, error);
			}
			return 1;
		}
	}