Example #1
0
reg_t kResCheck(EngineState *s, int argc, reg_t *argv) {
	Resource *res = NULL;
	ResourceType restype = g_sci->getResMan()->convertResType(argv[0].toUint16());

	if (restype == kResourceTypeVMD) {
		char fileName[10];
		sprintf(fileName, "%d.vmd", argv[1].toUint16());
		return make_reg(0, Common::File::exists(fileName));
	}

	if ((restype == kResourceTypeAudio36) || (restype == kResourceTypeSync36)) {
		if (argc >= 6) {
			uint noun = argv[2].toUint16() & 0xff;
			uint verb = argv[3].toUint16() & 0xff;
			uint cond = argv[4].toUint16() & 0xff;
			uint seq = argv[5].toUint16() & 0xff;

			res = g_sci->getResMan()->testResource(ResourceId(restype, argv[1].toUint16(), noun, verb, cond, seq));
		}
	} else {
		res = g_sci->getResMan()->testResource(ResourceId(restype, argv[1].toUint16()));
	}

	return make_reg(0, res != NULL);
}
Example #2
0
  ImageViewer(IReplayDriver *proxy, const char *filename)
      : m_Proxy(proxy), m_Filename(filename), m_TextureID()
  {
    if(m_Proxy == NULL)
      RDCERR("Unexpectedly NULL proxy at creation of ImageViewer");

    m_Props.pipelineType = ePipelineState_D3D11;
    m_Props.degraded = false;

    m_FrameRecord.frameInfo.fileOffset = 0;
    m_FrameRecord.frameInfo.firstEvent = 1;
    m_FrameRecord.frameInfo.frameNumber = 1;
    m_FrameRecord.frameInfo.immContextId = ResourceId();
    RDCEraseEl(m_FrameRecord.frameInfo.stats);

    create_array_uninit(m_FrameRecord.drawcallList, 1);
    FetchDrawcall &d = m_FrameRecord.drawcallList[0];
    d.context = ResourceId();
    d.drawcallID = 1;
    d.eventID = 1;
    d.name = filename;

    RefreshFile();

    create_array_uninit(m_PipelineState.m_OM.RenderTargets, 1);
    m_PipelineState.m_OM.RenderTargets[0].Resource = m_TextureID;
  }
Example #3
0
bool WrappedOpenGL::Serialise_glBindSamplers(GLuint first, GLsizei count, const GLuint *samplers)
{
  SERIALISE_ELEMENT(uint32_t, First, first);
  SERIALISE_ELEMENT(int32_t, Count, count);

  GLuint *samps = NULL;
  if(m_State <= EXECUTING)
    samps = new GLuint[Count];

  for(int32_t i = 0; i < Count; i++)
  {
    SERIALISE_ELEMENT(ResourceId, id,
                      samplers && samplers[i]
                          ? GetResourceManager()->GetID(SamplerRes(GetCtx(), samplers[i]))
                          : ResourceId());

    if(m_State <= EXECUTING)
    {
      if(id != ResourceId())
        samps[i] = GetResourceManager()->GetLiveResource(id).name;
      else
        samps[i] = 0;
    }
  }

  if(m_State <= EXECUTING)
  {
    m_Real.glBindSamplers(First, Count, samps);

    delete[] samps;
  }

  return true;
}
Example #4
0
void SoundCommandParser::initSoundResource(MusicEntry *newSound) {
	if (newSound->resourceId && _resMan->testResource(ResourceId(kResourceTypeSound, newSound->resourceId)))
		newSound->soundRes = new SoundResource(newSound->resourceId, _resMan, _soundVersion);
	else
		newSound->soundRes = 0;

	// In SCI1.1 games, sound effects are started from here. If we can find
	// a relevant audio resource, play it, otherwise switch to synthesized
	// effects. If the resource exists, play it using map 65535 (sound
	// effects map)
	bool checkAudioResource = getSciVersion() >= SCI_VERSION_1_1;
	// Hoyle 4 has garbled audio resources in place of the sound resources.
	// The demo of GK1 has no alternate sound effects.
	if ((g_sci->getGameId() == GID_HOYLE4) || 
		(g_sci->getGameId() == GID_GK1 && g_sci->isDemo()))
		checkAudioResource = false;

	if (checkAudioResource && _resMan->testResource(ResourceId(kResourceTypeAudio, newSound->resourceId))) {
		// Found a relevant audio resource, create an audio stream if there is
		// no associated sound resource, or if both resources exist and the
		// user wants the digital version.
		if (_bMultiMidi || !newSound->soundRes) {
			int sampleLen;
			newSound->pStreamAud = _audio->getAudioStream(newSound->resourceId, 65535, &sampleLen);
			newSound->soundType = Audio::Mixer::kSpeechSoundType;
		}
	}

	if (!newSound->pStreamAud && newSound->soundRes)
		_music->soundInitSnd(newSound);
}
Example #5
0
GfxFontFromResource::GfxFontFromResource(ResourceManager *resMan, GfxScreen *screen, GuiResourceId resourceId)
	: _resourceId(resourceId), _screen(screen), _resMan(resMan) {
	assert(resourceId != -1);

	// Workaround: lsl1sci mixes its own internal fonts with the global
	// SCI ones, so we translate them here, by removing their extra bits
	if (!resMan->testResource(ResourceId(kResourceTypeFont, resourceId)))
		resourceId = resourceId & 0x7ff;

	_resource = resMan->findResource(ResourceId(kResourceTypeFont, resourceId), true);
	if (!_resource) {
		error("font resource %d not found", resourceId);
	}
	_resourceData = _resource->data;

	_numChars = READ_SCI32ENDIAN_UINT16(_resourceData + 2);
	_fontHeight = READ_SCI32ENDIAN_UINT16(_resourceData + 4);
	_chars = new Charinfo[_numChars];
	// filling info for every char
	for (int16 i = 0; i < _numChars; i++) {
		_chars[i].offset = READ_SCI32ENDIAN_UINT16(_resourceData + 6 + i * 2);
		_chars[i].w = _resourceData[_chars[i].offset];
		_chars[i].h = _resourceData[_chars[i].offset + 1];
	}
}
Example #6
0
ReplayOutput::ReplayOutput(ReplayRenderer *parent, void *w)
{
	m_pRenderer = parent;

	m_MainOutput.dirty = true;

	m_OverlayDirty = true;

	m_pDevice = parent->GetDevice();

	m_OverlayResourceId = ResourceId();

	RDCEraseEl(m_RenderData);
	
	m_PixelContext.wndHandle = 0;
	m_PixelContext.outputID = 0;
	m_PixelContext.texture = ResourceId();
	m_PixelContext.depthMode = false;

	m_ContextX = -1.0f;
	m_ContextY = -1.0f;

	m_Config.m_Type = eOutputType_None;

	if(w) m_MainOutput.outputID = m_pDevice->MakeOutputWindow(w, true);
	else m_MainOutput.outputID = 0;
	m_MainOutput.texture = ResourceId();
	
	m_pDevice->GetOutputWindowDimensions(m_MainOutput.outputID, m_Width, m_Height);

	m_FirstDeferredEvent = 0;
	m_LastDeferredEvent = 0;

	m_CustomShaderResourceId = ResourceId();
}
Example #7
0
ResourceId ReplayRenderer::BuildCustomShader(const wchar_t *entry, const wchar_t *source, const uint32_t compileFlags, ShaderStageType type, rdctype::wstr *errors)
{
	ResourceId id;
	string errs;
	
	switch(type)
	{
		case eShaderStage_Vertex:
		case eShaderStage_Hull:
		case eShaderStage_Domain:
		case eShaderStage_Geometry:
		case eShaderStage_Pixel:
		case eShaderStage_Compute:
			break;
		default:
			RDCERR("Unexpected type in BuildShader!");
			return ResourceId();
	}

	m_pDevice->BuildCustomShader(narrow(source), narrow(entry), compileFlags, type, &id, &errs);

	if(id != ResourceId())
		m_CustomShaders.insert(id);
	
	if(errors) *errors = widen(errs);

	return id;
}
bool WrappedOpenGL::Serialise_glNamedFramebufferTextureEXT(GLuint framebuffer, GLenum attachment, GLuint texture, GLint level)
{
	SERIALISE_ELEMENT(GLenum, Attach, attachment);
	SERIALISE_ELEMENT(ResourceId, id, GetResourceManager()->GetID(TextureRes(GetCtx(), texture)));
	SERIALISE_ELEMENT(int32_t, Level, level);
	SERIALISE_ELEMENT(ResourceId, fbid, (framebuffer == 0 ? ResourceId() : GetResourceManager()->GetID(FramebufferRes(GetCtx(), framebuffer))));
	
	if(m_State < WRITING)
	{
		GLResource res = GetResourceManager()->GetLiveResource(id);
		if(fbid == ResourceId())
		{
			glNamedFramebufferTextureEXT(0, Attach, res.name, Level);
		}
		else
		{
			GLResource fbres = GetResourceManager()->GetLiveResource(fbid);
			glNamedFramebufferTextureEXT(fbres.name, Attach, res.name, Level);
		}

		if(m_State == READING)
		{
			m_Textures[GetResourceManager()->GetLiveID(id)].creationFlags |= eTextureCreate_RTV;
		}
	}

	return true;
}
Example #9
0
void D3D12Descriptor::GetRefIDs(ResourceId &id, ResourceId &id2, FrameRefType &ref)
{
  id = ResourceId();
  id2 = ResourceId();
  ref = eFrameRef_Read;

  switch(GetType())
  {
    case D3D12Descriptor::TypeUndefined:
    case D3D12Descriptor::TypeSampler:
      // nothing to do - no resource here
      break;
    case D3D12Descriptor::TypeCBV:
      id = WrappedID3D12Resource::GetResIDFromAddr(nonsamp.cbv.BufferLocation);
      break;
    case D3D12Descriptor::TypeSRV: id = GetResID(nonsamp.resource); break;
    case D3D12Descriptor::TypeUAV:
      id2 = GetResID(nonsamp.uav.counterResource);
    // deliberate fall-through
    case D3D12Descriptor::TypeRTV:
    case D3D12Descriptor::TypeDSV:
      ref = eFrameRef_Write;
      id = GetResID(nonsamp.resource);
      break;
  }
}
TEST(ReferenceLinkerTest, LinkMangledReferencesAndAttributes) {
    std::unique_ptr<IAaptContext> context = test::ContextBuilder()
            .setCompilationPackage(u"com.app.test")
            .setPackageId(0x7f)
            .setNameManglerPolicy(NameManglerPolicy{ u"com.app.test", { u"com.android.support" } })
            .addSymbolSource(test::StaticSymbolSourceBuilder()
                                     .addPublicSymbol(u"@com.app.test:attr/com.android.support$foo",
                                                      ResourceId(0x7f010000),
                                                      test::AttributeBuilder()
                                                              .setTypeMask(ResTable_map::TYPE_COLOR)
                                                              .build())
                                     .build())
            .build();

    std::unique_ptr<ResourceTable> table = test::ResourceTableBuilder()
            .setPackageId(u"com.app.test", 0x7f)
            .addValue(u"@com.app.test:style/Theme", ResourceId(0x7f020000),
                      test::StyleBuilder().addItem(u"@com.android.support:attr/foo",
                                                   ResourceUtils::tryParseColor(u"#ff0000"))
                                          .build())
            .build();

    ReferenceLinker linker;
    ASSERT_TRUE(linker.consume(context.get(), table.get()));

    Style* style = test::getValue<Style>(table.get(), u"@com.app.test:style/Theme");
    ASSERT_NE(style, nullptr);
    ASSERT_EQ(1u, style->entries.size());
    AAPT_ASSERT_TRUE(style->entries.front().key.id);
    EXPECT_EQ(style->entries.front().key.id.value(), ResourceId(0x7f010000));
}
Example #11
0
void Script::init(int script_nr, ResourceManager *resMan) {
	Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, script_nr), 0);

	if (!script)
		error("Script %d not found", script_nr);

	_localsOffset = 0;
	_localsBlock = NULL;
	_localsCount = 0;

	_markedAsDeleted = false;

	_nr = script_nr;
	_buf = 0;
	_heapStart = 0;

	_scriptSize = script->size;
	_bufSize = script->size;
	_heapSize = 0;

	_lockers = 1;

	if (getSciVersion() == SCI_VERSION_0_EARLY) {
		_bufSize += READ_LE_UINT16(script->data) * 2;
	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
		// In SCI1.1 - SCI2.1, the heap was in a separate space from the script. We append
		// it to the end of the script, and adjust addressing accordingly.
		// However, since we address the heap with a 16-bit pointer, the
		// combined size of the stack and the heap must be 64KB. So far this has
		// worked for SCI11, SCI2 and SCI21 games. SCI3 games use a different
		// script format, and theoretically they can exceed the 64KB boundary
		// using relocation.
		Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, script_nr), 0);
		_bufSize += heap->size;
		_heapSize = heap->size;

		// Ensure that the start of the heap resource can be word-aligned.
		if (script->size & 2) {
			_bufSize++;
			_scriptSize++;
		}

		// As mentioned above, the script and the heap together should not exceed 64KB
		if (script->size + heap->size > 65535)
			error("Script and heap sizes combined exceed 64K. This means a fundamental "
					"design bug was made regarding SCI1.1 and newer games.\n"
					"Please report this error to the ScummVM team");
	} else if (getSciVersion() == SCI_VERSION_3) {
		// Check for scripts over 64KB. These won't work with the current 16-bit address
		// scheme. We need an overlaying mechanism, or a mechanism to split script parts
		// in different segments to handle these. For now, simply stop when such a script
		// is found.
		// TODO: Remove this once such a mechanism is in place
		if (script->size > 65535)
			error("TODO: SCI script %d is over 64KB - it's %d bytes long. This can't "
			      "be handled at the moment, thus stopping", script_nr, script->size);
	}
}
Example #12
0
bool WrappedOpenGL::Serialise_glUseProgramStages(GLuint pipeline, GLbitfield stages, GLuint program)
{
	SERIALISE_ELEMENT(ResourceId, pipe, GetResourceManager()->GetID(ProgramPipeRes(GetCtx(), pipeline)));
	SERIALISE_ELEMENT(uint32_t, Stages, stages);
	SERIALISE_ELEMENT(ResourceId, prog, (program ? GetResourceManager()->GetID(ProgramRes(GetCtx(), program)) : ResourceId()));

	if(m_State < WRITING)
	{
		if(prog != ResourceId())
		{
			ResourceId livePipeId = GetResourceManager()->GetLiveID(pipe);
			ResourceId liveProgId = GetResourceManager()->GetLiveID(prog);

			PipelineData &pipeDetails = m_Pipelines[livePipeId];
			ProgramData &progDetails = m_Programs[liveProgId];

			for(size_t s=0; s < 6; s++)
			{
				if(Stages & ShaderBit(s))
				{
					for(size_t sh=0; sh < progDetails.shaders.size(); sh++)
					{
						if(m_Shaders[ progDetails.shaders[sh] ].type == ShaderEnum(s))
						{
							pipeDetails.stagePrograms[s] = liveProgId;
							pipeDetails.stageShaders[s] = progDetails.shaders[sh];
							break;
						}
					}
				}
			}

			m_Real.glUseProgramStages(GetResourceManager()->GetLiveResource(pipe).name,
																Stages,
																GetResourceManager()->GetLiveResource(prog).name);
		}
		else
		{
			ResourceId livePipeId = GetResourceManager()->GetLiveID(pipe);
			PipelineData &pipeDetails = m_Pipelines[livePipeId];

			for(size_t s=0; s < 6; s++)
			{
				if(Stages & ShaderBit(s))
				{
					pipeDetails.stagePrograms[s] = ResourceId();
					pipeDetails.stageShaders[s] = ResourceId();
				}
			}

			m_Real.glUseProgramStages(GetResourceManager()->GetLiveResource(pipe).name,
																Stages,
																0);
		}
	}

	return true;
}
Example #13
0
void Script::load(ResourceManager *resMan) {
	Resource *script = resMan->findResource(ResourceId(kResourceTypeScript, _nr), 0);
	assert(script != 0);

	uint extraLocalsWorkaround = 0;
	if (g_sci->getGameId() == GID_FANMADE && _nr == 1 && script->size == 11140) {
		// WORKAROUND: Script 1 in Ocean Battle doesn't have enough locals to
		// fit the string showing how many shots are left (a nasty script bug,
		// corrupting heap memory). We add 10 more locals so that it has enough
		// space to use as the target for its kFormat operation. Fixes bug
		// #3059871.
		extraLocalsWorkaround = 10;
	}
	_bufSize += extraLocalsWorkaround * 2;

	_buf = (byte *)malloc(_bufSize);
	assert(_buf);

	assert(_bufSize >= script->size);
	memcpy(_buf, script->data, script->size);

	// Check scripts for matching signatures and patch those, if found
	matchSignatureAndPatch(_nr, _buf, script->size);

	if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
		Resource *heap = resMan->findResource(ResourceId(kResourceTypeHeap, _nr), 0);
		assert(heap != 0);

		_heapStart = _buf + _scriptSize;

		assert(_bufSize - _scriptSize <= heap->size);
		memcpy(_heapStart, heap->data, heap->size);
	}

	_exportTable = 0;
	_numExports = 0;
	_synonyms = 0;
	_numSynonyms = 0;
	
	if (getSciVersion() <= SCI_VERSION_1_LATE) {
		_exportTable = (const uint16 *)findBlockSCI0(SCI_OBJ_EXPORTS);
		if (_exportTable) {
			_numExports = READ_SCI11ENDIAN_UINT16(_exportTable + 1);
			_exportTable += 3;	// skip header plus 2 bytes (_exportTable is a uint16 pointer)
		}
		_synonyms = findBlockSCI0(SCI_OBJ_SYNONYMS);
		if (_synonyms) {
			_numSynonyms = READ_SCI11ENDIAN_UINT16(_synonyms + 2) / 4;
			_synonyms += 4;	// skip header
		}
		const byte* localsBlock = findBlockSCI0(SCI_OBJ_LOCALVARS);
		if (localsBlock) {
			_localsOffset = localsBlock - _buf + 4;
			_localsCount = (READ_LE_UINT16(_buf + _localsOffset - 2) - 4) >> 1;	// half block size
		}
	} else if (getSciVersion() >= SCI_VERSION_1_1 && getSciVersion() <= SCI_VERSION_2_1) {
Example #14
0
uint32_t ReplayOutput::PickVertex(uint32_t eventID, uint32_t x, uint32_t y, uint32_t *pickedInstance)
{
  FetchDrawcall *draw = m_pRenderer->GetDrawcallByEID(eventID);

  if(!draw)
    return ~0U;
  if(m_RenderData.meshDisplay.type == eMeshDataStage_Unknown)
    return ~0U;
  if((draw->flags & eDraw_Drawcall) == 0)
    return ~0U;

  MeshDisplay cfg = m_RenderData.meshDisplay;

  if(cfg.position.buf == ResourceId())
    return ~0U;

  cfg.position.buf = m_pDevice->GetLiveID(cfg.position.buf);
  cfg.position.idxbuf = m_pDevice->GetLiveID(cfg.position.idxbuf);
  cfg.second.buf = m_pDevice->GetLiveID(cfg.second.buf);
  cfg.second.idxbuf = m_pDevice->GetLiveID(cfg.second.idxbuf);

  *pickedInstance = 0;

  if(draw->flags & eDraw_Instanced)
  {
    uint32_t maxInst = 0;
    if(m_RenderData.meshDisplay.showPrevInstances)
      maxInst = RDCMAX(1U, m_RenderData.meshDisplay.curInstance);
    if(m_RenderData.meshDisplay.showAllInstances)
      maxInst = RDCMAX(1U, draw->numInstances);

    for(uint32_t inst = 0; inst < maxInst; inst++)
    {
      // get the 'most final' stage
      MeshFormat fmt = m_pDevice->GetPostVSBuffers(draw->eventID, inst, eMeshDataStage_GSOut);
      if(fmt.buf == ResourceId())
        fmt = m_pDevice->GetPostVSBuffers(draw->eventID, inst, eMeshDataStage_VSOut);

      cfg.position = fmt;

      uint32_t ret = m_pDevice->PickVertex(m_EventID, cfg, x, y);
      if(ret != ~0U)
      {
        *pickedInstance = inst;
        return ret;
      }
    }

    return ~0U;
  }
  else
  {
    return m_pDevice->PickVertex(m_EventID, cfg, x, y);
  }
}
ResourceId ResourceId::getParentResourceId() const {
  if (isRelationAccess()) {
    return ResourceId(db_id_);
  } else if (isBlockAccess()) {
    return ResourceId(db_id_, rel_id_);
  } else if (isTupleAccess()) {
    return ResourceId(db_id_, rel_id_, block_id_);
  } else {
    LOG(FATAL) << "Database level does not have any parent level.";
  }
}
Example #16
0
ResourceId D3D12RenderState::GetDSVID() const
{
  if(dsv.heap != ResourceId())
  {
    const D3D12Descriptor *desc = DescriptorFromPortableHandle(GetResourceManager(), dsv);

    RDCASSERT(desc->GetType() == D3D12Descriptor::TypeDSV);

    return GetResID(desc->nonsamp.resource);
  }

  return ResourceId();
}
Example #17
0
void ReplayOutput::DisplayContext()
{
  if(m_PixelContext.outputID == 0)
    return;
  float color[4] = {0.0f, 0.0f, 0.0f, 0.0f};
  m_pDevice->BindOutputWindow(m_PixelContext.outputID, false);

  if((m_Config.m_Type != eOutputType_TexDisplay) || (m_ContextX < 0.0f && m_ContextY < 0.0f) ||
     (m_RenderData.texDisplay.texid == ResourceId()))
  {
    m_pDevice->RenderCheckerboard(Vec3f(0.666f, 0.666f, 0.666f), Vec3f(0.333f, 0.333f, 0.333f));
    m_pDevice->FlipOutputWindow(m_PixelContext.outputID);
    return;
  }

  m_pDevice->ClearOutputWindowColour(m_PixelContext.outputID, color);

  TextureDisplay disp = m_RenderData.texDisplay;
  disp.rawoutput = false;
  disp.CustomShader = ResourceId();

  if(m_RenderData.texDisplay.CustomShader != ResourceId())
    disp.texid = m_CustomShaderResourceId;

  if((m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawDraw ||
      m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawPass) &&
     m_OverlayResourceId != ResourceId())
    disp.texid = m_OverlayResourceId;

  disp.scale = 8.0f;

  int32_t width = 0, height = 0;
  m_pDevice->GetOutputWindowDimensions(m_PixelContext.outputID, width, height);

  float w = (float)width;
  float h = (float)height;

  disp.offx = -m_ContextX * disp.scale;
  disp.offy = -m_ContextY * disp.scale;

  disp.offx += w / 2.0f;
  disp.offy += h / 2.0f;

  disp.texid = m_pDevice->GetLiveID(disp.texid);

  m_pDevice->RenderTexture(disp);

  m_pDevice->RenderHighlightBox(w, h, disp.scale);

  m_pDevice->FlipOutputWindow(m_PixelContext.outputID);
}
Example #18
0
bool ReplayOutput::PickPixel(ResourceId tex, bool customShader, uint32_t x, uint32_t y,
                             uint32_t sliceFace, uint32_t mip, uint32_t sample, PixelValue *ret)
{
  if(ret == NULL || tex == ResourceId())
    return false;

  RDCEraseEl(ret->value_f);

  bool decodeRamp = false;

  FormatComponentType typeHint = m_RenderData.texDisplay.typeHint;

  if(customShader && m_RenderData.texDisplay.CustomShader != ResourceId() &&
     m_CustomShaderResourceId != ResourceId())
  {
    tex = m_CustomShaderResourceId;
    typeHint = eCompType_None;
  }
  if((m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawDraw ||
      m_RenderData.texDisplay.overlay == eTexOverlay_QuadOverdrawPass) &&
     m_OverlayResourceId != ResourceId())
  {
    decodeRamp = true;
    tex = m_OverlayResourceId;
    typeHint = eCompType_None;
  }

  m_pDevice->PickPixel(m_pDevice->GetLiveID(tex), x, y, sliceFace, mip, sample, typeHint,
                       ret->value_f);

  if(decodeRamp)
  {
    for(size_t c = 0; c < ARRAY_COUNT(overdrawRamp); c++)
    {
      if(fabs(ret->value_f[0] - overdrawRamp[c].x) < 0.00005f &&
         fabs(ret->value_f[1] - overdrawRamp[c].y) < 0.00005f &&
         fabs(ret->value_f[2] - overdrawRamp[c].z) < 0.00005f)
      {
        ret->value_i[0] = (int32_t)c;
        ret->value_i[1] = 0;
        ret->value_i[2] = 0;
        ret->value_i[3] = 0;
        break;
      }
    }
  }

  return true;
}
TEST_F(TransactionTableTest, NormalOperations) {
  const AccessMode is_lock_mode = AccessMode::IsLockMode();
  const AccessMode x_lock_mode = AccessMode::XLockMode();

  EXPECT_EQ(TransactionTableResult::kPlacedInOwned,
            transaction_table_.putOwnEntry(tid_1_,
                                           ResourceId(3),
                                           is_lock_mode));


  EXPECT_EQ(TransactionTableResult::kPlacedInPending,
            transaction_table_.putPendingEntry(tid_1_,
                                               ResourceId(5),
                                               x_lock_mode));
}
Example #20
0
static void console_command_reload(ConsoleServer& /*cs*/, TCPSocket /*client*/, const char* json)
{
	TempAllocator4096 ta;
	JsonObject obj(ta);
	DynamicString type(ta);
	DynamicString name(ta);

	sjson::parse(json, obj);
	sjson::parse_string(obj["resource_type"], type);
	sjson::parse_string(obj["resource_name"], name);

	logi("Reloading resource '%s.%s'", name.c_str(), type.c_str());
	device()->reload(ResourceId(type.c_str()), ResourceId(name.c_str()));
	logi("Reloaded resource '%s.%s'", name.c_str(), type.c_str());
}
Example #21
0
void CaptureContext::LoadRenames(const QString &data)
{
  QVariantMap root = JSONToVariant(data);

  if(root.contains(lit("CustomResourceNames")))
  {
    QVariantMap resources = root[lit("CustomResourceNames")].toMap();

    for(const QString &str : resources.keys())
    {
      ResourceId id;

      if(str.startsWith(lit("resourceid::")))
      {
        qulonglong num = str.mid(sizeof("resourceid::") - 1).toULongLong();
        memcpy(&id, &num, sizeof(num));
      }
      else
      {
        qCritical() << "Unrecognised resourceid encoding" << str;
      }

      if(id != ResourceId())
        m_CustomNames[id] = resources[str].toString();
    }
  }
}
Example #22
0
void GfxMacIconBar::drawIcons() {
	// Draw the icons to the bottom of the screen

	byte *pal = new byte[256 * 4];
	Graphics::PictDecoder *pict = new Graphics::PictDecoder(Graphics::PixelFormat::createFormatCLUT8());
	uint32 lastX = 0;

	for (uint32 i = 0; i < _iconBarObjects.size(); i++) {
		uint32 iconIndex = readSelectorValue(g_sci->getEngineState()->_segMan, _iconBarObjects[i], SELECTOR(iconIndex));
		Resource *res = g_sci->getResMan()->findResource(ResourceId(kResourceTypeMacIconBarPictN, iconIndex + 1), false);
		if (!res)
			continue;

		Common::SeekableReadStream *stream = new Common::MemoryReadStream(res->data, res->size);
		Graphics::Surface *surf = pict->decodeImage(stream, pal);
		remapColors(surf, pal);

		g_system->copyRectToScreen((byte *)surf->pixels, surf->pitch, lastX, 200, MIN<uint32>(surf->w, 320 - lastX), surf->h);

		lastX += surf->w;
		surf->free();
		delete surf;
		delete stream;
	}

	delete pict;
	delete[] pal;
}
Example #23
0
bool ReplayOutput::GetMinMax(PixelValue *minval, PixelValue *maxval)
{
  PixelValue *a = minval;
  PixelValue *b = maxval;

  PixelValue dummy;

  if(a == NULL)
    a = &dummy;
  if(b == NULL)
    b = &dummy;

  ResourceId tex = m_pDevice->GetLiveID(m_RenderData.texDisplay.texid);

  FormatComponentType typeHint = m_RenderData.texDisplay.typeHint;
  uint32_t slice = m_RenderData.texDisplay.sliceFace;
  uint32_t mip = m_RenderData.texDisplay.mip;
  uint32_t sample = m_RenderData.texDisplay.sampleIdx;

  if(m_RenderData.texDisplay.CustomShader != ResourceId() && m_CustomShaderResourceId != ResourceId())
  {
    tex = m_CustomShaderResourceId;
    typeHint = eCompType_None;
    slice = 0;
    sample = 0;
  }

  return m_pDevice->GetMinMax(tex, slice, mip, sample, typeHint, &a->value_f[0], &b->value_f[0]);
}
Example #24
0
bool ReplayOutput::GetHistogram(float minval, float maxval, bool channels[4],
                                rdctype::array<uint32_t> *histogram)
{
  if(histogram == NULL)
    return false;

  vector<uint32_t> hist;

  ResourceId tex = m_pDevice->GetLiveID(m_RenderData.texDisplay.texid);

  FormatComponentType typeHint = m_RenderData.texDisplay.typeHint;
  uint32_t slice = m_RenderData.texDisplay.sliceFace;
  uint32_t mip = m_RenderData.texDisplay.mip;
  uint32_t sample = m_RenderData.texDisplay.sampleIdx;

  if(m_RenderData.texDisplay.CustomShader != ResourceId() && m_CustomShaderResourceId != ResourceId())
  {
    tex = m_CustomShaderResourceId;
    typeHint = eCompType_None;
    slice = 0;
    sample = 0;
  }

  bool ret =
      m_pDevice->GetHistogram(tex, slice, mip, sample, typeHint, minval, maxval, channels, hist);

  if(ret)
    *histogram = hist;

  return ret;
}
Example #25
0
reg_t SoundCommandParser::kDoSoundSetPriority(int argc, reg_t *argv, reg_t acc) {
	reg_t obj = argv[0];
	int16 value = argv[1].toSint16();

	debugC(kDebugLevelSound, "kDoSound(setPriority): %04x:%04x, %d", PRINT_REG(obj), value);

	MusicEntry *musicSlot = _music->getSlot(obj);
	if (!musicSlot) {
		debugC(kDebugLevelSound, "kDoSound(setPriority): Slot not found (%04x:%04x)", PRINT_REG(obj));
		return acc;
	}

	if (value == -1) {
		uint16 resourceId = musicSlot->resourceId;

		// Set priority from the song data
		Resource *song = _resMan->findResource(ResourceId(kResourceTypeSound, resourceId), 0);
		if (song->data[0] == 0xf0)
			_music->soundSetPriority(musicSlot, song->data[1]);
		else
			warning("kDoSound(setPriority): Attempt to unset song priority when there is no built-in value");

		//pSnd->prio=0;field_15B=0
		writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) & 0xFD);
	} else {
		// Scripted priority

		//pSnd->field_15B=1;
		writeSelectorValue(_segMan, obj, SELECTOR(flags), readSelectorValue(_segMan, obj, SELECTOR(flags)) | 2);
		//DoSOund(0xF,hobj,w)
	}
	return acc;
}
Example #26
0
void LockerImpl<IsForMMAPV1>::getLockerInfo(LockerInfo* lockerInfo) const {
    invariant(lockerInfo);

    // Zero-out the contents
    lockerInfo->locks.clear();
    lockerInfo->waitingResource = ResourceId();
    lockerInfo->stats.reset();

    _lock.lock();
    LockRequestsMap::ConstIterator it = _requests.begin();
    while (!it.finished()) {
        OneLock info;
        info.resourceId = it.key();
        info.mode = it->mode;

        lockerInfo->locks.push_back(info);
        it.next();
    }
    _lock.unlock();

    std::sort(lockerInfo->locks.begin(), lockerInfo->locks.end());

    lockerInfo->waitingResource = getWaitingResource();
    lockerInfo->stats.append(_stats);
}
Example #27
0
void TextureViewer::OnEventSelected(uint32_t frameID, uint32_t eventID)
{
	m_Core->Renderer()->AsyncInvoke([this](IReplayRenderer *) {
		TextureDisplay d;
		if(m_Core->APIProps().pipelineType == ePipelineState_D3D11)
			d.texid = m_Core->CurD3D11PipelineState.m_OM.RenderTargets[0].Resource;
		else
			d.texid = m_Core->CurGLPipelineState.m_FB.m_DrawFBO.Color[0];
		d.mip = 0;
		d.sampleIdx = ~0U;
		d.overlay = eTexOverlay_None;
		d.CustomShader = ResourceId();
		d.HDRMul = -1.0f;
		d.linearDisplayAsGamma = true;
		d.FlipY = false;
		d.rangemin = 0.0f;
		d.rangemax = 1.0f;
		d.scale = -1.0f;
		d.offx = 0.0f;
		d.offy = 0.0f;
		d.sliceFace = 0;
		d.rawoutput = false;
		d.lightBackgroundColour = d.darkBackgroundColour =
			FloatVector(0.0f, 0.0f, 0.0f, 0.0f);
		d.Red = d.Green = d.Blue = true;
		d.Alpha = false;
		m_Output->SetTextureDisplay(d);

		GUIInvoke::call([this]() { ui->render->update(); });
	});
}
Example #28
0
	ResourceId parse_resource_id(const char* json)
	{
		TempAllocator1024 ta;
		DynamicString str(ta);
		sjson::parse_string(json, str);
		return ResourceId(str.c_str());
	}
Example #29
0
D3D12RenderState::D3D12RenderState()
{
  views.clear();
  scissors.clear();

  rts.clear();
  rtSingle = false;
  dsv = PortableHandle();

  m_ResourceManager = NULL;

  heaps.clear();

  pipe = graphics.rootsig = compute.rootsig = ResourceId();
  graphics.sigelems.clear();
  compute.sigelems.clear();

  topo = D3D_PRIMITIVE_TOPOLOGY_UNDEFINED;

  stencilRef = 0;
  RDCEraseEl(blendFactor);

  RDCEraseEl(ibuffer);
  vbuffers.clear();
}
Example #30
0
GLsync WrappedOpenGL::glFenceSync(GLenum condition, GLbitfield flags)
{
	GLsync sync = m_Real.glFenceSync(condition, flags);
	
	GLuint name = 0;
	ResourceId id = ResourceId();
	GetResourceManager()->RegisterSync(sync, name, id);
	GLResource res = SyncRes(name);

	if(m_State == WRITING_CAPFRAME)
	{
		Chunk *chunk = NULL;

		{
			SCOPED_SERIALISE_CONTEXT(FENCE_SYNC);
			Serialise_glFenceSync(sync, condition, flags);

			chunk = scope.Get();
		}

		m_ContextRecord->AddChunk(chunk);
	}
	else
	{
		GetResourceManager()->AddLiveResource(id, res);
	}

	return sync;
}